
/******************************************************************************
******************************************************************************/
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[TF_CountryInsert]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
	drop procedure [dbo].[TF_CountryInsert]
GO

CREATE PROCEDURE [dbo].[TF_CountryInsert] (
	@CountryID int,
	@CountryName varchar(100),
	@Description varchar(100),
	@LanguageId int
)

AS

SET NOCOUNT ON

INSERT INTO [TF_Country] (
	[CountryID],
	[CountryName],
	[Description],
	[LanguageId]
) VALUES (
	@CountryID,
	@CountryName,
	@Description,
	@LanguageId
)

SELECT SCOPE_IDENTITY()
GO

/******************************************************************************
******************************************************************************/
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[TF_CountryUpdate]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
	drop procedure [dbo].[TF_CountryUpdate]
GO

CREATE PROCEDURE [dbo].[TF_CountryUpdate] (
	@Id int,
	@CountryID int,
	@CountryName varchar(100),
	@Description varchar(100),
	@LanguageId int
)

AS

SET NOCOUNT ON

UPDATE
	[TF_Country]
SET
	[CountryID] = @CountryID,
	[CountryName] = @CountryName,
	[Description] = @Description,
	[LanguageId] = @LanguageId
WHERE
	 [Id] = @Id
GO

/******************************************************************************
******************************************************************************/
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[TF_CountryDelete]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
	drop procedure [dbo].[TF_CountryDelete]
GO

CREATE PROCEDURE [dbo].[TF_CountryDelete] (
	@Id int
)

AS

SET NOCOUNT ON

DELETE FROM
	[TF_Country]
WHERE
	[Id] = @Id
GO

/******************************************************************************
******************************************************************************/
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[TF_CountrySelect]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
	drop procedure [dbo].[TF_CountrySelect]
GO

CREATE PROCEDURE [dbo].[TF_CountrySelect] (
	@Id int
)

AS

SET NOCOUNT ON

SELECT
	[Id],
	[CountryID],
	[CountryName],
	[Description],
	[LanguageId]
FROM
	[TF_Country]
WHERE
	[Id] = @Id
GO

/******************************************************************************
******************************************************************************/
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[TF_CountrySelectAll]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
	drop procedure [dbo].[TF_CountrySelectAll]
GO

CREATE PROCEDURE [dbo].[TF_CountrySelectAll]

AS

SET NOCOUNT ON

SELECT
	[Id],
	[CountryID],
	[CountryName],
	[Description],
	[LanguageId]
FROM
	[TF_Country]
GO

/******************************************************************************
******************************************************************************/
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[TF_UnSheduleCityInsert]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
	drop procedure [dbo].[TF_UnSheduleCityInsert]
GO

CREATE PROCEDURE [dbo].[TF_UnSheduleCityInsert] (
	@EventId int,
	@CityId int,
	@LanuageId int,
	@LocCode varchar(30)
)

AS

SET NOCOUNT ON

INSERT INTO [TF_UnSheduleCity] (
	[EventId],
	[CityId],
	[LanuageId],
	[LocCode]
) VALUES (
	@EventId,
	@CityId,
	@LanuageId,
	@LocCode
)

SELECT SCOPE_IDENTITY()
GO

/******************************************************************************
******************************************************************************/
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[TF_EventLineInsert]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
	drop procedure [dbo].[TF_EventLineInsert]
GO

CREATE PROCEDURE [dbo].[TF_EventLineInsert] (
	@EventId int,
	@Seq int,
	@StartDate varchar(10),
	@StartTime varchar(8),
	@EndDate varchar(10),
	@EndTime varchar(8),
	@CityIDFrom int,
	@CityIDTo int,
	@LinePrice decimal(18, 2),
	@TTID int,
	@IsReturn bit,
	@Remark varchar(500),
	@LanuageId int,
	@ScheduleStatus int,
	@StepDay int,
	@CityId int
)

AS

SET NOCOUNT ON

INSERT INTO [TF_EventLine] (
	[EventId],
	[Seq],
	[StartDate],
	[StartTime],
	[EndDate],
	[EndTime],
	[CityIDFrom],
	[CityIDTo],
	[LinePrice],
	[TTID],
	[IsReturn],
	[Remark],
	[LanuageId],
	[ScheduleStatus],
	[StepDay],
	[CityId]
) VALUES (
	@EventId,
	@Seq,
	@StartDate,
	@StartTime,
	@EndDate,
	@EndTime,
	@CityIDFrom,
	@CityIDTo,
	@LinePrice,
	@TTID,
	@IsReturn,
	@Remark,
	@LanuageId,
	@ScheduleStatus,
	@StepDay,
	@CityId
)

SELECT SCOPE_IDENTITY()
GO

/******************************************************************************
******************************************************************************/
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[TF_EventLineUpdate]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
	drop procedure [dbo].[TF_EventLineUpdate]
GO

CREATE PROCEDURE [dbo].[TF_EventLineUpdate] (
	@EventLineId int,
	@EventId int,
	@Seq int,
	@StartDate varchar(10),
	@StartTime varchar(8),
	@EndDate varchar(10),
	@EndTime varchar(8),
	@CityIDFrom int,
	@CityIDTo int,
	@LinePrice decimal(18, 2),
	@TTID int,
	@IsReturn bit,
	@Remark varchar(500),
	@LanuageId int,
	@ScheduleStatus int,
	@StepDay int,
	@CityId int
)

AS

SET NOCOUNT ON

UPDATE
	[TF_EventLine]
SET
	[EventId] = @EventId,
	[Seq] = @Seq,
	[StartDate] = @StartDate,
	[StartTime] = @StartTime,
	[EndDate] = @EndDate,
	[EndTime] = @EndTime,
	[CityIDFrom] = @CityIDFrom,
	[CityIDTo] = @CityIDTo,
	[LinePrice] = @LinePrice,
	[TTID] = @TTID,
	[IsReturn] = @IsReturn,
	[Remark] = @Remark,
	[LanuageId] = @LanuageId,
	[ScheduleStatus] = @ScheduleStatus,
	[StepDay] = @StepDay,
	[CityId] = @CityId
WHERE
	 [EventLineId] = @EventLineId
GO

/******************************************************************************
******************************************************************************/
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[TF_EventLineDelete]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
	drop procedure [dbo].[TF_EventLineDelete]
GO

CREATE PROCEDURE [dbo].[TF_EventLineDelete] (
	@EventLineId int
)

AS

SET NOCOUNT ON

DELETE FROM
	[TF_EventLine]
WHERE
	[EventLineId] = @EventLineId
GO

/******************************************************************************
******************************************************************************/
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[TF_EventLineSelect]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
	drop procedure [dbo].[TF_EventLineSelect]
GO

CREATE PROCEDURE [dbo].[TF_EventLineSelect] (
	@EventLineId int
)

AS

SET NOCOUNT ON

SELECT
	[EventLineId],
	[EventId],
	[Seq],
	[StartDate],
	[StartTime],
	[EndDate],
	[EndTime],
	[CityIDFrom],
	[CityIDTo],
	[LinePrice],
	[TTID],
	[IsReturn],
	[Remark],
	[LanuageId],
	[ScheduleStatus],
	[StepDay],
	[CityId]
FROM
	[TF_EventLine]
WHERE
	[EventLineId] = @EventLineId
GO

/******************************************************************************
******************************************************************************/
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[TF_EventLineSelectAll]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
	drop procedure [dbo].[TF_EventLineSelectAll]
GO

CREATE PROCEDURE [dbo].[TF_EventLineSelectAll]

AS

SET NOCOUNT ON

SELECT
	[EventLineId],
	[EventId],
	[Seq],
	[StartDate],
	[StartTime],
	[EndDate],
	[EndTime],
	[CityIDFrom],
	[CityIDTo],
	[LinePrice],
	[TTID],
	[IsReturn],
	[Remark],
	[LanuageId],
	[ScheduleStatus],
	[StepDay],
	[CityId]
FROM
	[TF_EventLine]
GO

/******************************************************************************
******************************************************************************/
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[TF_CityInsert]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
	drop procedure [dbo].[TF_CityInsert]
GO

CREATE PROCEDURE [dbo].[TF_CityInsert] (
	@CityID int,
	@CityName varchar(100),
	@CountryID int,
	@ProvinceID int,
	@IpAddressL varchar(50),
	@IpAddressH varchar(50),
	@LanuageId int,
	@Description varchar(2000),
	@LocCode varchar(30),
	@Name varchar(100)
)

AS

SET NOCOUNT ON

INSERT INTO [TF_City] (
	[CityID],
	[CityName],
	[CountryID],
	[ProvinceID],
	[IpAddressL],
	[IpAddressH],
	[LanuageId],
	[Description],
	[LocCode],
	[Name]
) VALUES (
	@CityID,
	@CityName,
	@CountryID,
	@ProvinceID,
	@IpAddressL,
	@IpAddressH,
	@LanuageId,
	@Description,
	@LocCode,
	@Name
)

SELECT SCOPE_IDENTITY()
GO

/******************************************************************************
******************************************************************************/
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[TF_CityUpdate]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
	drop procedure [dbo].[TF_CityUpdate]
GO

CREATE PROCEDURE [dbo].[TF_CityUpdate] (
	@ID int,
	@CityID int,
	@CityName varchar(100),
	@CountryID int,
	@ProvinceID int,
	@IpAddressL varchar(50),
	@IpAddressH varchar(50),
	@LanuageId int,
	@Description varchar(2000),
	@LocCode varchar(30),
	@Name varchar(100)
)

AS

SET NOCOUNT ON

UPDATE
	[TF_City]
SET
	[CityID] = @CityID,
	[CityName] = @CityName,
	[CountryID] = @CountryID,
	[ProvinceID] = @ProvinceID,
	[IpAddressL] = @IpAddressL,
	[IpAddressH] = @IpAddressH,
	[LanuageId] = @LanuageId,
	[Description] = @Description,
	[LocCode] = @LocCode,
	[Name] = @Name
WHERE
	 [ID] = @ID
GO

/******************************************************************************
******************************************************************************/
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[TF_CityDelete]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
	drop procedure [dbo].[TF_CityDelete]
GO

CREATE PROCEDURE [dbo].[TF_CityDelete] (
	@ID int
)

AS

SET NOCOUNT ON

DELETE FROM
	[TF_City]
WHERE
	[ID] = @ID
GO

/******************************************************************************
******************************************************************************/
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[TF_CitySelect]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
	drop procedure [dbo].[TF_CitySelect]
GO

CREATE PROCEDURE [dbo].[TF_CitySelect] (
	@ID int
)

AS

SET NOCOUNT ON

SELECT
	[ID],
	[CityID],
	[CityName],
	[CountryID],
	[ProvinceID],
	[IpAddressL],
	[IpAddressH],
	[LanuageId],
	[Description],
	[LocCode],
	[Name]
FROM
	[TF_City]
WHERE
	[ID] = @ID
GO

/******************************************************************************
******************************************************************************/
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[TF_CitySelectAll]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
	drop procedure [dbo].[TF_CitySelectAll]
GO

CREATE PROCEDURE [dbo].[TF_CitySelectAll]

AS

SET NOCOUNT ON

SELECT
	[ID],
	[CityID],
	[CityName],
	[CountryID],
	[ProvinceID],
	[IpAddressL],
	[IpAddressH],
	[LanuageId],
	[Description],
	[LocCode],
	[Name]
FROM
	[TF_City]
GO

/******************************************************************************
******************************************************************************/
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[TF_HotelInsert]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
	drop procedure [dbo].[TF_HotelInsert]
GO

CREATE PROCEDURE [dbo].[TF_HotelInsert] (
	@HotelID int,
	@Name varchar(100),
	@Description varchar(2000),
	@Detail ntext,
	@ImageURL varchar(100),
	@CityID int,
	@LanuageId int,
	@Star int,
	@Rating int,
	@Address varchar(500),
	@Telephone varchar(50),
	@Fax varchar(20),
	@OpenTime varchar(30),
	@UnitPrice int,
	@OverView varchar(500),
	@URL varchar(500),
	@LocCode varchar(30)
)

AS

SET NOCOUNT ON

INSERT INTO [TF_Hotel] (
	[HotelID],
	[Name],
	[Description],
	[Detail],
	[ImageURL],
	[CityID],
	[LanuageId],
	[Star],
	[Rating],
	[Address],
	[Telephone],
	[Fax],
	[OpenTime],
	[UnitPrice],
	[OverView],
	[URL],
	[LocCode]
) VALUES (
	@HotelID,
	@Name,
	@Description,
	@Detail,
	@ImageURL,
	@CityID,
	@LanuageId,
	@Star,
	@Rating,
	@Address,
	@Telephone,
	@Fax,
	@OpenTime,
	@UnitPrice,
	@OverView,
	@URL,
	@LocCode
)

SELECT SCOPE_IDENTITY()
GO

/******************************************************************************
******************************************************************************/
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[TF_HotelUpdate]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
	drop procedure [dbo].[TF_HotelUpdate]
GO

CREATE PROCEDURE [dbo].[TF_HotelUpdate] (
	@ID int,
	@HotelID int,
	@Name varchar(100),
	@Description varchar(2000),
	@Detail ntext,
	@ImageURL varchar(100),
	@CityID int,
	@LanuageId int,
	@Star int,
	@Rating int,
	@Address varchar(500),
	@Telephone varchar(50),
	@Fax varchar(20),
	@OpenTime varchar(30),
	@UnitPrice int,
	@OverView varchar(500),
	@URL varchar(500),
	@LocCode varchar(30)
)

AS

SET NOCOUNT ON

UPDATE
	[TF_Hotel]
SET
	[HotelID] = @HotelID,
	[Name] = @Name,
	[Description] = @Description,
	[Detail] = @Detail,
	[ImageURL] = @ImageURL,
	[CityID] = @CityID,
	[LanuageId] = @LanuageId,
	[Star] = @Star,
	[Rating] = @Rating,
	[Address] = @Address,
	[Telephone] = @Telephone,
	[Fax] = @Fax,
	[OpenTime] = @OpenTime,
	[UnitPrice] = @UnitPrice,
	[OverView] = @OverView,
	[URL] = @URL,
	[LocCode] = @LocCode
WHERE
	 [ID] = @ID
GO

/******************************************************************************
******************************************************************************/
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[TF_HotelDelete]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
	drop procedure [dbo].[TF_HotelDelete]
GO

CREATE PROCEDURE [dbo].[TF_HotelDelete] (
	@ID int
)

AS

SET NOCOUNT ON

DELETE FROM
	[TF_Hotel]
WHERE
	[ID] = @ID
GO

/******************************************************************************
******************************************************************************/
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[TF_HotelSelect]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
	drop procedure [dbo].[TF_HotelSelect]
GO

CREATE PROCEDURE [dbo].[TF_HotelSelect] (
	@ID int
)

AS

SET NOCOUNT ON

SELECT
	[ID],
	[HotelID],
	[Name],
	[Description],
	[Detail],
	[ImageURL],
	[CityID],
	[LanuageId],
	[Star],
	[Rating],
	[Address],
	[Telephone],
	[Fax],
	[OpenTime],
	[UnitPrice],
	[OverView],
	[URL],
	[LocCode]
FROM
	[TF_Hotel]
WHERE
	[ID] = @ID
GO

/******************************************************************************
******************************************************************************/
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[TF_HotelSelectAll]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
	drop procedure [dbo].[TF_HotelSelectAll]
GO

CREATE PROCEDURE [dbo].[TF_HotelSelectAll]

AS

SET NOCOUNT ON

SELECT
	[ID],
	[HotelID],
	[Name],
	[Description],
	[Detail],
	[ImageURL],
	[CityID],
	[LanuageId],
	[Star],
	[Rating],
	[Address],
	[Telephone],
	[Fax],
	[OpenTime],
	[UnitPrice],
	[OverView],
	[URL],
	[LocCode]
FROM
	[TF_Hotel]
GO

/******************************************************************************
******************************************************************************/
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[IPInsert]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
	drop procedure [dbo].[IPInsert]
GO

CREATE PROCEDURE [dbo].[IPInsert] (
	@Field1 varchar(16),
	@Field2 varchar(16),
	@Field3 varchar(5),
	@Field4 varchar(31),
	@Field5 varchar(3)
)

AS

SET NOCOUNT ON

INSERT INTO [IP] (
	[Field1],
	[Field2],
	[Field3],
	[Field4],
	[Field5]
) VALUES (
	@Field1,
	@Field2,
	@Field3,
	@Field4,
	@Field5
)

SELECT SCOPE_IDENTITY()
GO

/******************************************************************************
******************************************************************************/
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[IPUpdate]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
	drop procedure [dbo].[IPUpdate]
GO

CREATE PROCEDURE [dbo].[IPUpdate] (
	@ID int,
	@Field1 varchar(16),
	@Field2 varchar(16),
	@Field3 varchar(5),
	@Field4 varchar(31),
	@Field5 varchar(3)
)

AS

SET NOCOUNT ON

UPDATE
	[IP]
SET
	[Field1] = @Field1,
	[Field2] = @Field2,
	[Field3] = @Field3,
	[Field4] = @Field4,
	[Field5] = @Field5
WHERE
	 [ID] = @ID
GO

/******************************************************************************
******************************************************************************/
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[IPDelete]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
	drop procedure [dbo].[IPDelete]
GO

CREATE PROCEDURE [dbo].[IPDelete] (
	@ID int
)

AS

SET NOCOUNT ON

DELETE FROM
	[IP]
WHERE
	[ID] = @ID
GO

/******************************************************************************
******************************************************************************/
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[IPSelect]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
	drop procedure [dbo].[IPSelect]
GO

CREATE PROCEDURE [dbo].[IPSelect] (
	@ID int
)

AS

SET NOCOUNT ON

SELECT
	[ID],
	[Field1],
	[Field2],
	[Field3],
	[Field4],
	[Field5]
FROM
	[IP]
WHERE
	[ID] = @ID
GO

/******************************************************************************
******************************************************************************/
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[IPSelectAll]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
	drop procedure [dbo].[IPSelectAll]
GO

CREATE PROCEDURE [dbo].[IPSelectAll]

AS

SET NOCOUNT ON

SELECT
	[ID],
	[Field1],
	[Field2],
	[Field3],
	[Field4],
	[Field5]
FROM
	[IP]
GO

/******************************************************************************
******************************************************************************/
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[TF_ProvinceInsert]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
	drop procedure [dbo].[TF_ProvinceInsert]
GO

CREATE PROCEDURE [dbo].[TF_ProvinceInsert] (
	@ProvinceID int,
	@Provice_Name varchar(100),
	@CountryID int,
	@LanguageID int,
	@IsSameCity int,
	@LocCode varchar(30),
	@Name varchar(100)
)

AS

SET NOCOUNT ON

INSERT INTO [TF_Province] (
	[ProvinceID],
	[Provice_Name],
	[CountryID],
	[LanguageID],
	[IsSameCity],
	[LocCode],
	[Name]
) VALUES (
	@ProvinceID,
	@Provice_Name,
	@CountryID,
	@LanguageID,
	@IsSameCity,
	@LocCode,
	@Name
)

SELECT SCOPE_IDENTITY()
GO

/******************************************************************************
******************************************************************************/
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[TF_ProvinceUpdate]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
	drop procedure [dbo].[TF_ProvinceUpdate]
GO

CREATE PROCEDURE [dbo].[TF_ProvinceUpdate] (
	@ID int,
	@ProvinceID int,
	@Provice_Name varchar(100),
	@CountryID int,
	@LanguageID int,
	@IsSameCity int,
	@LocCode varchar(30),
	@Name varchar(100)
)

AS

SET NOCOUNT ON

UPDATE
	[TF_Province]
SET
	[ProvinceID] = @ProvinceID,
	[Provice_Name] = @Provice_Name,
	[CountryID] = @CountryID,
	[LanguageID] = @LanguageID,
	[IsSameCity] = @IsSameCity,
	[LocCode] = @LocCode,
	[Name] = @Name
WHERE
	 [ID] = @ID
GO

/******************************************************************************
******************************************************************************/
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[TF_ProvinceDelete]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
	drop procedure [dbo].[TF_ProvinceDelete]
GO

CREATE PROCEDURE [dbo].[TF_ProvinceDelete] (
	@ID int
)

AS

SET NOCOUNT ON

DELETE FROM
	[TF_Province]
WHERE
	[ID] = @ID
GO

/******************************************************************************
******************************************************************************/
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[TF_ProvinceSelect]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
	drop procedure [dbo].[TF_ProvinceSelect]
GO

CREATE PROCEDURE [dbo].[TF_ProvinceSelect] (
	@ID int
)

AS

SET NOCOUNT ON

SELECT
	[ID],
	[ProvinceID],
	[Provice_Name],
	[CountryID],
	[LanguageID],
	[IsSameCity],
	[LocCode],
	[Name]
FROM
	[TF_Province]
WHERE
	[ID] = @ID
GO

/******************************************************************************
******************************************************************************/
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[TF_ProvinceSelectAll]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
	drop procedure [dbo].[TF_ProvinceSelectAll]
GO

CREATE PROCEDURE [dbo].[TF_ProvinceSelectAll]

AS

SET NOCOUNT ON

SELECT
	[ID],
	[ProvinceID],
	[Provice_Name],
	[CountryID],
	[LanguageID],
	[IsSameCity],
	[LocCode],
	[Name]
FROM
	[TF_Province]
GO

/******************************************************************************
******************************************************************************/
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[tf_event_logInsert]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
	drop procedure [dbo].[tf_event_logInsert]
GO

CREATE PROCEDURE [dbo].[tf_event_logInsert] (
	@uid int,
	@user_nick_name varchar(50),
	@user_pic varchar(100),
	@ele_id int,
	@ele_name varchar(300),
	@log_type varchar(5),
	@keyin_date datetime
)

AS

SET NOCOUNT ON

INSERT INTO [tf_event_log] (
	[uid],
	[user_nick_name],
	[user_pic],
	[ele_id],
	[ele_name],
	[log_type],
	[keyin_date]
) VALUES (
	@uid,
	@user_nick_name,
	@user_pic,
	@ele_id,
	@ele_name,
	@log_type,
	@keyin_date
)

SELECT SCOPE_IDENTITY()
GO

/******************************************************************************
******************************************************************************/
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[tf_event_logUpdate]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
	drop procedure [dbo].[tf_event_logUpdate]
GO

CREATE PROCEDURE [dbo].[tf_event_logUpdate] (
	@id int,
	@uid int,
	@user_nick_name varchar(50),
	@user_pic varchar(100),
	@ele_id int,
	@ele_name varchar(300),
	@log_type varchar(5),
	@keyin_date datetime
)

AS

SET NOCOUNT ON

UPDATE
	[tf_event_log]
SET
	[uid] = @uid,
	[user_nick_name] = @user_nick_name,
	[user_pic] = @user_pic,
	[ele_id] = @ele_id,
	[ele_name] = @ele_name,
	[log_type] = @log_type,
	[keyin_date] = @keyin_date
WHERE
	 [id] = @id
GO

/******************************************************************************
******************************************************************************/
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[tf_event_logDelete]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
	drop procedure [dbo].[tf_event_logDelete]
GO

CREATE PROCEDURE [dbo].[tf_event_logDelete] (
	@id int
)

AS

SET NOCOUNT ON

DELETE FROM
	[tf_event_log]
WHERE
	[id] = @id
GO

/******************************************************************************
******************************************************************************/
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[tf_event_logSelect]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
	drop procedure [dbo].[tf_event_logSelect]
GO

CREATE PROCEDURE [dbo].[tf_event_logSelect] (
	@id int
)

AS

SET NOCOUNT ON

SELECT
	[id],
	[uid],
	[user_nick_name],
	[user_pic],
	[ele_id],
	[ele_name],
	[log_type],
	[keyin_date]
FROM
	[tf_event_log]
WHERE
	[id] = @id
GO

/******************************************************************************
******************************************************************************/
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[tf_event_logSelectAll]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
	drop procedure [dbo].[tf_event_logSelectAll]
GO

CREATE PROCEDURE [dbo].[tf_event_logSelectAll]

AS

SET NOCOUNT ON

SELECT
	[id],
	[uid],
	[user_nick_name],
	[user_pic],
	[ele_id],
	[ele_name],
	[log_type],
	[keyin_date]
FROM
	[tf_event_log]
GO

/******************************************************************************
******************************************************************************/
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[TF_EventDetailInsert]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
	drop procedure [dbo].[TF_EventDetailInsert]
GO

CREATE PROCEDURE [dbo].[TF_EventDetailInsert] (
	@EventHId int,
	@ToCityId int,
	@PreCityId int,
	@StartDate datetime,
	@EndDate datetime,
	@DayNumber int
)

AS

SET NOCOUNT ON

INSERT INTO [TF_EventDetail] (
	[EventHId],
	[ToCityId],
	[PreCityId],
	[StartDate],
	[EndDate],
	[DayNumber]
) VALUES (
	@EventHId,
	@ToCityId,
	@PreCityId,
	@StartDate,
	@EndDate,
	@DayNumber
)

SELECT SCOPE_IDENTITY()
GO

/******************************************************************************
******************************************************************************/
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[TF_EventDetailUpdate]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
	drop procedure [dbo].[TF_EventDetailUpdate]
GO

CREATE PROCEDURE [dbo].[TF_EventDetailUpdate] (
	@id int,
	@EventHId int,
	@ToCityId int,
	@PreCityId int,
	@StartDate datetime,
	@EndDate datetime,
	@DayNumber int
)

AS

SET NOCOUNT ON

UPDATE
	[TF_EventDetail]
SET
	[EventHId] = @EventHId,
	[ToCityId] = @ToCityId,
	[PreCityId] = @PreCityId,
	[StartDate] = @StartDate,
	[EndDate] = @EndDate,
	[DayNumber] = @DayNumber
WHERE
	 [id] = @id
GO

/******************************************************************************
******************************************************************************/
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[TF_EventDetailDelete]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
	drop procedure [dbo].[TF_EventDetailDelete]
GO

CREATE PROCEDURE [dbo].[TF_EventDetailDelete] (
	@id int
)

AS

SET NOCOUNT ON

DELETE FROM
	[TF_EventDetail]
WHERE
	[id] = @id
GO

/******************************************************************************
******************************************************************************/
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[TF_EventDetailSelect]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
	drop procedure [dbo].[TF_EventDetailSelect]
GO

CREATE PROCEDURE [dbo].[TF_EventDetailSelect] (
	@id int
)

AS

SET NOCOUNT ON

SELECT
	[id],
	[EventHId],
	[ToCityId],
	[PreCityId],
	[StartDate],
	[EndDate],
	[DayNumber]
FROM
	[TF_EventDetail]
WHERE
	[id] = @id
GO

/******************************************************************************
******************************************************************************/
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[TF_EventDetailSelectAll]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
	drop procedure [dbo].[TF_EventDetailSelectAll]
GO

CREATE PROCEDURE [dbo].[TF_EventDetailSelectAll]

AS

SET NOCOUNT ON

SELECT
	[id],
	[EventHId],
	[ToCityId],
	[PreCityId],
	[StartDate],
	[EndDate],
	[DayNumber]
FROM
	[TF_EventDetail]
GO

/******************************************************************************
******************************************************************************/
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[TF_MarketInsert]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
	drop procedure [dbo].[TF_MarketInsert]
GO

CREATE PROCEDURE [dbo].[TF_MarketInsert] (
	@MarketID int,
	@MarketName varchar(100),
	@Description varchar(2000),
	@Detail ntext,
	@ImageURL varchar(100),
	@CityId int,
	@LanguageID int,
	@LocCode varchar(30)
)

AS

SET NOCOUNT ON

INSERT INTO [TF_Market] (
	[MarketID],
	[MarketName],
	[Description],
	[Detail],
	[ImageURL],
	[CityId],
	[LanguageID],
	[LocCode]
) VALUES (
	@MarketID,
	@MarketName,
	@Description,
	@Detail,
	@ImageURL,
	@CityId,
	@LanguageID,
	@LocCode
)

SELECT SCOPE_IDENTITY()
GO

/******************************************************************************
******************************************************************************/
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[TF_MarketUpdate]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
	drop procedure [dbo].[TF_MarketUpdate]
GO

CREATE PROCEDURE [dbo].[TF_MarketUpdate] (
	@ID int,
	@MarketID int,
	@MarketName varchar(100),
	@Description varchar(2000),
	@Detail ntext,
	@ImageURL varchar(100),
	@CityId int,
	@LanguageID int,
	@LocCode varchar(30)
)

AS

SET NOCOUNT ON

UPDATE
	[TF_Market]
SET
	[MarketID] = @MarketID,
	[MarketName] = @MarketName,
	[Description] = @Description,
	[Detail] = @Detail,
	[ImageURL] = @ImageURL,
	[CityId] = @CityId,
	[LanguageID] = @LanguageID,
	[LocCode] = @LocCode
WHERE
	 [ID] = @ID
GO

/******************************************************************************
******************************************************************************/
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[TF_MarketDelete]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
	drop procedure [dbo].[TF_MarketDelete]
GO

CREATE PROCEDURE [dbo].[TF_MarketDelete] (
	@ID int
)

AS

SET NOCOUNT ON

DELETE FROM
	[TF_Market]
WHERE
	[ID] = @ID
GO

/******************************************************************************
******************************************************************************/
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[TF_MarketSelect]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
	drop procedure [dbo].[TF_MarketSelect]
GO

CREATE PROCEDURE [dbo].[TF_MarketSelect] (
	@ID int
)

AS

SET NOCOUNT ON

SELECT
	[ID],
	[MarketID],
	[MarketName],
	[Description],
	[Detail],
	[ImageURL],
	[CityId],
	[LanguageID],
	[LocCode]
FROM
	[TF_Market]
WHERE
	[ID] = @ID
GO

/******************************************************************************
******************************************************************************/
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[TF_MarketSelectAll]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
	drop procedure [dbo].[TF_MarketSelectAll]
GO

CREATE PROCEDURE [dbo].[TF_MarketSelectAll]

AS

SET NOCOUNT ON

SELECT
	[ID],
	[MarketID],
	[MarketName],
	[Description],
	[Detail],
	[ImageURL],
	[CityId],
	[LanguageID],
	[LocCode]
FROM
	[TF_Market]
GO

/******************************************************************************
******************************************************************************/
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[TF_ViewInsert]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
	drop procedure [dbo].[TF_ViewInsert]
GO

CREATE PROCEDURE [dbo].[TF_ViewInsert] (
	@Name varchar(100),
	@Description varchar(2000),
	@Detail ntext,
	@CityID int,
	@DistinctId int,
	@Position int,
	@LanuageId int,
	@ViewPrice decimal(18, 2),
	@type_id int,
	@Type varchar(50),
	@Star int,
	@Rating int,
	@Address varchar(500),
	@Telephone varchar(50),
	@Fax varchar(20),
	@OpenTime varchar(30),
	@UnitPrice int,
	@OverView varchar(500),
	@URL varchar(500),
	@LocCode varchar(30),
	@ImageURL varchar(100),
	@lat float(53),
	@lng float(53)
)

AS

SET NOCOUNT ON

INSERT INTO [TF_View] (
	[Name],
	[Description],
	[Detail],
	[CityID],
	[DistinctId],
	[Position],
	[LanuageId],
	[ViewPrice],
	[type_id],
	[Type],
	[Star],
	[Rating],
	[Address],
	[Telephone],
	[Fax],
	[OpenTime],
	[UnitPrice],
	[OverView],
	[URL],
	[LocCode],
	[ImageURL],
	[lat],
	[lng]
) VALUES (
	@Name,
	@Description,
	@Detail,
	@CityID,
	@DistinctId,
	@Position,
	@LanuageId,
	@ViewPrice,
	@type_id,
	@Type,
	@Star,
	@Rating,
	@Address,
	@Telephone,
	@Fax,
	@OpenTime,
	@UnitPrice,
	@OverView,
	@URL,
	@LocCode,
	@ImageURL,
	@lat,
	@lng
)

SELECT SCOPE_IDENTITY()
GO

/******************************************************************************
******************************************************************************/
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[TF_ViewUpdate]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
	drop procedure [dbo].[TF_ViewUpdate]
GO

CREATE PROCEDURE [dbo].[TF_ViewUpdate] (
	@ID int,
	@Name varchar(100),
	@Description varchar(2000),
	@Detail ntext,
	@CityID int,
	@DistinctId int,
	@Position int,
	@LanuageId int,
	@ViewPrice decimal(18, 2),
	@type_id int,
	@Type varchar(50),
	@Star int,
	@Rating int,
	@Address varchar(500),
	@Telephone varchar(50),
	@Fax varchar(20),
	@OpenTime varchar(30),
	@UnitPrice int,
	@OverView varchar(500),
	@URL varchar(500),
	@LocCode varchar(30),
	@ImageURL varchar(100),
	@lat float(53),
	@lng float(53)
)

AS

SET NOCOUNT ON

UPDATE
	[TF_View]
SET
	[Name] = @Name,
	[Description] = @Description,
	[Detail] = @Detail,
	[CityID] = @CityID,
	[DistinctId] = @DistinctId,
	[Position] = @Position,
	[LanuageId] = @LanuageId,
	[ViewPrice] = @ViewPrice,
	[type_id] = @type_id,
	[Type] = @Type,
	[Star] = @Star,
	[Rating] = @Rating,
	[Address] = @Address,
	[Telephone] = @Telephone,
	[Fax] = @Fax,
	[OpenTime] = @OpenTime,
	[UnitPrice] = @UnitPrice,
	[OverView] = @OverView,
	[URL] = @URL,
	[LocCode] = @LocCode,
	[ImageURL] = @ImageURL,
	[lat] = @lat,
	[lng] = @lng
WHERE
	 [ID] = @ID
GO

/******************************************************************************
******************************************************************************/
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[TF_ViewDelete]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
	drop procedure [dbo].[TF_ViewDelete]
GO

CREATE PROCEDURE [dbo].[TF_ViewDelete] (
	@ID int
)

AS

SET NOCOUNT ON

DELETE FROM
	[TF_View]
WHERE
	[ID] = @ID
GO

/******************************************************************************
******************************************************************************/
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[TF_ViewSelect]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
	drop procedure [dbo].[TF_ViewSelect]
GO

CREATE PROCEDURE [dbo].[TF_ViewSelect] (
	@ID int
)

AS

SET NOCOUNT ON

SELECT
	[ID],
	[Name],
	[Description],
	[Detail],
	[CityID],
	[DistinctId],
	[Position],
	[LanuageId],
	[ViewPrice],
	[type_id],
	[Type],
	[Star],
	[Rating],
	[Address],
	[Telephone],
	[Fax],
	[OpenTime],
	[UnitPrice],
	[OverView],
	[URL],
	[LocCode],
	[ImageURL],
	[lat],
	[lng]
FROM
	[TF_View]
WHERE
	[ID] = @ID
GO

/******************************************************************************
******************************************************************************/
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[TF_ViewSelectAll]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
	drop procedure [dbo].[TF_ViewSelectAll]
GO

CREATE PROCEDURE [dbo].[TF_ViewSelectAll]

AS

SET NOCOUNT ON

SELECT
	[ID],
	[Name],
	[Description],
	[Detail],
	[CityID],
	[DistinctId],
	[Position],
	[LanuageId],
	[ViewPrice],
	[type_id],
	[Type],
	[Star],
	[Rating],
	[Address],
	[Telephone],
	[Fax],
	[OpenTime],
	[UnitPrice],
	[OverView],
	[URL],
	[LocCode],
	[ImageURL],
	[lat],
	[lng]
FROM
	[TF_View]
GO

/******************************************************************************
******************************************************************************/
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[TF_RestaurantInsert]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
	drop procedure [dbo].[TF_RestaurantInsert]
GO

CREATE PROCEDURE [dbo].[TF_RestaurantInsert] (
	@RestaurantId int,
	@Name varchar(100),
	@Description varchar(2000),
	@Detail ntext,
	@ImageURL varchar(100),
	@CityID int,
	@LanuageId int,
	@OverView varchar(500),
	@Star int,
	@Rating int,
	@Address varchar(500),
	@Telephone varchar(50),
	@Fax varchar(20),
	@OpenTime varchar(30),
	@UnitPrice int,
	@StartHour int,
	@StartMin int,
	@Duration int,
	@TimeStatus int,
	@LocCode varchar(30)
)

AS

SET NOCOUNT ON

INSERT INTO [TF_Restaurant] (
	[RestaurantId],
	[Name],
	[Description],
	[Detail],
	[ImageURL],
	[CityID],
	[LanuageId],
	[OverView],
	[Star],
	[Rating],
	[Address],
	[Telephone],
	[Fax],
	[OpenTime],
	[UnitPrice],
	[StartHour],
	[StartMin],
	[Duration],
	[TimeStatus],
	[LocCode]
) VALUES (
	@RestaurantId,
	@Name,
	@Description,
	@Detail,
	@ImageURL,
	@CityID,
	@LanuageId,
	@OverView,
	@Star,
	@Rating,
	@Address,
	@Telephone,
	@Fax,
	@OpenTime,
	@UnitPrice,
	@StartHour,
	@StartMin,
	@Duration,
	@TimeStatus,
	@LocCode
)

SELECT SCOPE_IDENTITY()
GO

/******************************************************************************
******************************************************************************/
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[TF_RestaurantUpdate]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
	drop procedure [dbo].[TF_RestaurantUpdate]
GO

CREATE PROCEDURE [dbo].[TF_RestaurantUpdate] (
	@ID int,
	@RestaurantId int,
	@Name varchar(100),
	@Description varchar(2000),
	@Detail ntext,
	@ImageURL varchar(100),
	@CityID int,
	@LanuageId int,
	@OverView varchar(500),
	@Star int,
	@Rating int,
	@Address varchar(500),
	@Telephone varchar(50),
	@Fax varchar(20),
	@OpenTime varchar(30),
	@UnitPrice int,
	@StartHour int,
	@StartMin int,
	@Duration int,
	@TimeStatus int,
	@LocCode varchar(30)
)

AS

SET NOCOUNT ON

UPDATE
	[TF_Restaurant]
SET
	[RestaurantId] = @RestaurantId,
	[Name] = @Name,
	[Description] = @Description,
	[Detail] = @Detail,
	[ImageURL] = @ImageURL,
	[CityID] = @CityID,
	[LanuageId] = @LanuageId,
	[OverView] = @OverView,
	[Star] = @Star,
	[Rating] = @Rating,
	[Address] = @Address,
	[Telephone] = @Telephone,
	[Fax] = @Fax,
	[OpenTime] = @OpenTime,
	[UnitPrice] = @UnitPrice,
	[StartHour] = @StartHour,
	[StartMin] = @StartMin,
	[Duration] = @Duration,
	[TimeStatus] = @TimeStatus,
	[LocCode] = @LocCode
WHERE
	 [ID] = @ID
GO

/******************************************************************************
******************************************************************************/
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[TF_RestaurantDelete]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
	drop procedure [dbo].[TF_RestaurantDelete]
GO

CREATE PROCEDURE [dbo].[TF_RestaurantDelete] (
	@ID int
)

AS

SET NOCOUNT ON

DELETE FROM
	[TF_Restaurant]
WHERE
	[ID] = @ID
GO

/******************************************************************************
******************************************************************************/
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[TF_RestaurantSelect]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
	drop procedure [dbo].[TF_RestaurantSelect]
GO

CREATE PROCEDURE [dbo].[TF_RestaurantSelect] (
	@ID int
)

AS

SET NOCOUNT ON

SELECT
	[ID],
	[RestaurantId],
	[Name],
	[Description],
	[Detail],
	[ImageURL],
	[CityID],
	[LanuageId],
	[OverView],
	[Star],
	[Rating],
	[Address],
	[Telephone],
	[Fax],
	[OpenTime],
	[UnitPrice],
	[StartHour],
	[StartMin],
	[Duration],
	[TimeStatus],
	[LocCode]
FROM
	[TF_Restaurant]
WHERE
	[ID] = @ID
GO

/******************************************************************************
******************************************************************************/
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[TF_RestaurantSelectAll]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
	drop procedure [dbo].[TF_RestaurantSelectAll]
GO

CREATE PROCEDURE [dbo].[TF_RestaurantSelectAll]

AS

SET NOCOUNT ON

SELECT
	[ID],
	[RestaurantId],
	[Name],
	[Description],
	[Detail],
	[ImageURL],
	[CityID],
	[LanuageId],
	[OverView],
	[Star],
	[Rating],
	[Address],
	[Telephone],
	[Fax],
	[OpenTime],
	[UnitPrice],
	[StartHour],
	[StartMin],
	[Duration],
	[TimeStatus],
	[LocCode]
FROM
	[TF_Restaurant]
GO

/******************************************************************************
******************************************************************************/
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[TF_EventViewInsert]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
	drop procedure [dbo].[TF_EventViewInsert]
GO

CREATE PROCEDURE [dbo].[TF_EventViewInsert] (
	@CityID int,
	@ViewId int,
	@ViewPrice float(53),
	@StartDate datetime,
	@EndDate datetime,
	@Memo varchar(500)
)

AS

SET NOCOUNT ON

INSERT INTO [TF_EventView] (
	[CityID],
	[ViewId],
	[ViewPrice],
	[StartDate],
	[EndDate],
	[Memo]
) VALUES (
	@CityID,
	@ViewId,
	@ViewPrice,
	@StartDate,
	@EndDate,
	@Memo
)

SELECT SCOPE_IDENTITY()
GO

/******************************************************************************
******************************************************************************/
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[TF_EventViewUpdate]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
	drop procedure [dbo].[TF_EventViewUpdate]
GO

CREATE PROCEDURE [dbo].[TF_EventViewUpdate] (
	@id int,
	@CityID int,
	@ViewId int,
	@ViewPrice float(53),
	@StartDate datetime,
	@EndDate datetime,
	@Memo varchar(500)
)

AS

SET NOCOUNT ON

UPDATE
	[TF_EventView]
SET
	[CityID] = @CityID,
	[ViewId] = @ViewId,
	[ViewPrice] = @ViewPrice,
	[StartDate] = @StartDate,
	[EndDate] = @EndDate,
	[Memo] = @Memo
WHERE
	 [id] = @id
GO

/******************************************************************************
******************************************************************************/
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[TF_EventViewDelete]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
	drop procedure [dbo].[TF_EventViewDelete]
GO

CREATE PROCEDURE [dbo].[TF_EventViewDelete] (
	@id int
)

AS

SET NOCOUNT ON

DELETE FROM
	[TF_EventView]
WHERE
	[id] = @id
GO

/******************************************************************************
******************************************************************************/
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[TF_EventViewSelect]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
	drop procedure [dbo].[TF_EventViewSelect]
GO

CREATE PROCEDURE [dbo].[TF_EventViewSelect] (
	@id int
)

AS

SET NOCOUNT ON

SELECT
	[id],
	[CityID],
	[ViewId],
	[ViewPrice],
	[StartDate],
	[EndDate],
	[Memo]
FROM
	[TF_EventView]
WHERE
	[id] = @id
GO

/******************************************************************************
******************************************************************************/
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[TF_EventViewSelectAll]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
	drop procedure [dbo].[TF_EventViewSelectAll]
GO

CREATE PROCEDURE [dbo].[TF_EventViewSelectAll]

AS

SET NOCOUNT ON

SELECT
	[id],
	[CityID],
	[ViewId],
	[ViewPrice],
	[StartDate],
	[EndDate],
	[Memo]
FROM
	[TF_EventView]
GO

/******************************************************************************
******************************************************************************/
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[tf_picsInsert]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
	drop procedure [dbo].[tf_picsInsert]
GO

CREATE PROCEDURE [dbo].[tf_picsInsert] (
	@album_id int,
	@album_name nvarchar(50),
	@title nvarchar(50),
	@pic_url varchar(800),
	@memo nvarchar(200),
	@note nvarchar(500),
	@public_type varchar(5),
	@owner_id int,
	@upload_date datetime
)

AS

SET NOCOUNT ON

INSERT INTO [tf_pics] (
	[album_id],
	[album_name],
	[title],
	[pic_url],
	[memo],
	[note],
	[public_type],
	[owner_id],
	[upload_date]
) VALUES (
	@album_id,
	@album_name,
	@title,
	@pic_url,
	@memo,
	@note,
	@public_type,
	@owner_id,
	@upload_date
)

SELECT SCOPE_IDENTITY()
GO

/******************************************************************************
******************************************************************************/
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[tf_picsUpdate]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
	drop procedure [dbo].[tf_picsUpdate]
GO

CREATE PROCEDURE [dbo].[tf_picsUpdate] (
	@id int,
	@album_id int,
	@album_name nvarchar(50),
	@title nvarchar(50),
	@pic_url varchar(800),
	@memo nvarchar(200),
	@note nvarchar(500),
	@public_type varchar(5),
	@owner_id int,
	@upload_date datetime
)

AS

SET NOCOUNT ON

UPDATE
	[tf_pics]
SET
	[album_id] = @album_id,
	[album_name] = @album_name,
	[title] = @title,
	[pic_url] = @pic_url,
	[memo] = @memo,
	[note] = @note,
	[public_type] = @public_type,
	[owner_id] = @owner_id,
	[upload_date] = @upload_date
WHERE
	 [id] = @id
GO

/******************************************************************************
******************************************************************************/
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[tf_picsDelete]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
	drop procedure [dbo].[tf_picsDelete]
GO

CREATE PROCEDURE [dbo].[tf_picsDelete] (
	@id int
)

AS

SET NOCOUNT ON

DELETE FROM
	[tf_pics]
WHERE
	[id] = @id
GO

/******************************************************************************
******************************************************************************/
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[tf_picsSelect]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
	drop procedure [dbo].[tf_picsSelect]
GO

CREATE PROCEDURE [dbo].[tf_picsSelect] (
	@id int
)

AS

SET NOCOUNT ON

SELECT
	[id],
	[album_id],
	[album_name],
	[title],
	[pic_url],
	[memo],
	[note],
	[public_type],
	[owner_id],
	[upload_date]
FROM
	[tf_pics]
WHERE
	[id] = @id
GO

/******************************************************************************
******************************************************************************/
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[tf_picsSelectAll]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
	drop procedure [dbo].[tf_picsSelectAll]
GO

CREATE PROCEDURE [dbo].[tf_picsSelectAll]

AS

SET NOCOUNT ON

SELECT
	[id],
	[album_id],
	[album_name],
	[title],
	[pic_url],
	[memo],
	[note],
	[public_type],
	[owner_id],
	[upload_date]
FROM
	[tf_pics]
GO

/******************************************************************************
******************************************************************************/
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[TF_TravelToolInsert]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
	drop procedure [dbo].[TF_TravelToolInsert]
GO

CREATE PROCEDURE [dbo].[TF_TravelToolInsert] (
	@TTID int,
	@TTName varchar(100),
	@Description varchar(2000),
	@Detail ntext,
	@ImageURL varchar(100),
	@CityID int,
	@LanguageID int
)

AS

SET NOCOUNT ON

INSERT INTO [TF_TravelTool] (
	[TTID],
	[TTName],
	[Description],
	[Detail],
	[ImageURL],
	[CityID],
	[LanguageID]
) VALUES (
	@TTID,
	@TTName,
	@Description,
	@Detail,
	@ImageURL,
	@CityID,
	@LanguageID
)

SELECT SCOPE_IDENTITY()
GO

/******************************************************************************
******************************************************************************/
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[TF_TravelToolUpdate]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
	drop procedure [dbo].[TF_TravelToolUpdate]
GO

CREATE PROCEDURE [dbo].[TF_TravelToolUpdate] (
	@ID int,
	@TTID int,
	@TTName varchar(100),
	@Description varchar(2000),
	@Detail ntext,
	@ImageURL varchar(100),
	@CityID int,
	@LanguageID int
)

AS

SET NOCOUNT ON

UPDATE
	[TF_TravelTool]
SET
	[TTID] = @TTID,
	[TTName] = @TTName,
	[Description] = @Description,
	[Detail] = @Detail,
	[ImageURL] = @ImageURL,
	[CityID] = @CityID,
	[LanguageID] = @LanguageID
WHERE
	 [ID] = @ID
GO

/******************************************************************************
******************************************************************************/
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[TF_TravelToolDelete]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
	drop procedure [dbo].[TF_TravelToolDelete]
GO

CREATE PROCEDURE [dbo].[TF_TravelToolDelete] (
	@ID int
)

AS

SET NOCOUNT ON

DELETE FROM
	[TF_TravelTool]
WHERE
	[ID] = @ID
GO

/******************************************************************************
******************************************************************************/
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[TF_TravelToolSelect]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
	drop procedure [dbo].[TF_TravelToolSelect]
GO

CREATE PROCEDURE [dbo].[TF_TravelToolSelect] (
	@ID int
)

AS

SET NOCOUNT ON

SELECT
	[ID],
	[TTID],
	[TTName],
	[Description],
	[Detail],
	[ImageURL],
	[CityID],
	[LanguageID]
FROM
	[TF_TravelTool]
WHERE
	[ID] = @ID
GO

/******************************************************************************
******************************************************************************/
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[TF_TravelToolSelectAll]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
	drop procedure [dbo].[TF_TravelToolSelectAll]
GO

CREATE PROCEDURE [dbo].[TF_TravelToolSelectAll]

AS

SET NOCOUNT ON

SELECT
	[ID],
	[TTID],
	[TTName],
	[Description],
	[Detail],
	[ImageURL],
	[CityID],
	[LanguageID]
FROM
	[TF_TravelTool]
GO

/******************************************************************************
******************************************************************************/
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[tf_albumInsert]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
	drop procedure [dbo].[tf_albumInsert]
GO

CREATE PROCEDURE [dbo].[tf_albumInsert] (
	@album_name nvarchar(50),
	@owner_id int,
	@keyin_date datetime,
	@memo nvarchar(100)
)

AS

SET NOCOUNT ON

INSERT INTO [tf_album] (
	[album_name],
	[owner_id],
	[keyin_date],
	[memo]
) VALUES (
	@album_name,
	@owner_id,
	@keyin_date,
	@memo
)

SELECT SCOPE_IDENTITY()
GO

/******************************************************************************
******************************************************************************/
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[tf_albumUpdate]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
	drop procedure [dbo].[tf_albumUpdate]
GO

CREATE PROCEDURE [dbo].[tf_albumUpdate] (
	@id int,
	@album_name nvarchar(50),
	@owner_id int,
	@keyin_date datetime,
	@memo nvarchar(100)
)

AS

SET NOCOUNT ON

UPDATE
	[tf_album]
SET
	[album_name] = @album_name,
	[owner_id] = @owner_id,
	[keyin_date] = @keyin_date,
	[memo] = @memo
WHERE
	 [id] = @id
GO

/******************************************************************************
******************************************************************************/
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[tf_albumDelete]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
	drop procedure [dbo].[tf_albumDelete]
GO

CREATE PROCEDURE [dbo].[tf_albumDelete] (
	@id int
)

AS

SET NOCOUNT ON

DELETE FROM
	[tf_album]
WHERE
	[id] = @id
GO

/******************************************************************************
******************************************************************************/
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[tf_albumSelect]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
	drop procedure [dbo].[tf_albumSelect]
GO

CREATE PROCEDURE [dbo].[tf_albumSelect] (
	@id int
)

AS

SET NOCOUNT ON

SELECT
	[id],
	[album_name],
	[owner_id],
	[keyin_date],
	[memo]
FROM
	[tf_album]
WHERE
	[id] = @id
GO

/******************************************************************************
******************************************************************************/
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[tf_albumSelectAll]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
	drop procedure [dbo].[tf_albumSelectAll]
GO

CREATE PROCEDURE [dbo].[tf_albumSelectAll]

AS

SET NOCOUNT ON

SELECT
	[id],
	[album_name],
	[owner_id],
	[keyin_date],
	[memo]
FROM
	[tf_album]
GO

/******************************************************************************
******************************************************************************/
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[TF_EventHInsert]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
	drop procedure [dbo].[TF_EventHInsert]
GO

CREATE PROCEDURE [dbo].[TF_EventHInsert] (
	@EventTitle varchar(250),
	@StartDate datetime,
	@EndDate datetime,
	@dueDays int,
	@Memo varchar(2000),
	@PicUrl varchar(250),
	@OwnerId int,
	@CreateDate datetime,
	@TotalCost float(53),
	@AttendCount int,
	@StarNum int,
	@PublicType varchar(1),
	@StartCityId int,
	@EventCities varchar(5000),
	@AttentionCount int
)

AS

SET NOCOUNT ON

INSERT INTO [TF_EventH] (
	[EventTitle],
	[StartDate],
	[EndDate],
	[dueDays],
	[Memo],
	[PicUrl],
	[OwnerId],
	[CreateDate],
	[TotalCost],
	[AttendCount],
	[StarNum],
	[PublicType],
	[StartCityId],
	[EventCities],
	[AttentionCount]
) VALUES (
	@EventTitle,
	@StartDate,
	@EndDate,
	@dueDays,
	@Memo,
	@PicUrl,
	@OwnerId,
	@CreateDate,
	@TotalCost,
	@AttendCount,
	@StarNum,
	@PublicType,
	@StartCityId,
	@EventCities,
	@AttentionCount
)

SELECT SCOPE_IDENTITY()
GO

/******************************************************************************
******************************************************************************/
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[TF_EventHUpdate]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
	drop procedure [dbo].[TF_EventHUpdate]
GO

CREATE PROCEDURE [dbo].[TF_EventHUpdate] (
	@Id int,
	@EventTitle varchar(250),
	@StartDate datetime,
	@EndDate datetime,
	@dueDays int,
	@Memo varchar(2000),
	@PicUrl varchar(250),
	@OwnerId int,
	@CreateDate datetime,
	@TotalCost float(53),
	@AttendCount int,
	@StarNum int,
	@PublicType varchar(1),
	@StartCityId int,
	@EventCities varchar(5000),
	@AttentionCount int
)

AS

SET NOCOUNT ON

UPDATE
	[TF_EventH]
SET
	[EventTitle] = @EventTitle,
	[StartDate] = @StartDate,
	[EndDate] = @EndDate,
	[dueDays] = @dueDays,
	[Memo] = @Memo,
	[PicUrl] = @PicUrl,
	[OwnerId] = @OwnerId,
	[CreateDate] = @CreateDate,
	[TotalCost] = @TotalCost,
	[AttendCount] = @AttendCount,
	[StarNum] = @StarNum,
	[PublicType] = @PublicType,
	[StartCityId] = @StartCityId,
	[EventCities] = @EventCities,
	[AttentionCount] = @AttentionCount
WHERE
	 [Id] = @Id
GO

/******************************************************************************
******************************************************************************/
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[TF_EventHDelete]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
	drop procedure [dbo].[TF_EventHDelete]
GO

CREATE PROCEDURE [dbo].[TF_EventHDelete] (
	@Id int
)

AS

SET NOCOUNT ON

DELETE FROM
	[TF_EventH]
WHERE
	[Id] = @Id
GO

/******************************************************************************
******************************************************************************/
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[TF_EventHSelect]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
	drop procedure [dbo].[TF_EventHSelect]
GO

CREATE PROCEDURE [dbo].[TF_EventHSelect] (
	@Id int
)

AS

SET NOCOUNT ON

SELECT
	[Id],
	[EventTitle],
	[StartDate],
	[EndDate],
	[dueDays],
	[Memo],
	[PicUrl],
	[OwnerId],
	[CreateDate],
	[TotalCost],
	[AttendCount],
	[StarNum],
	[PublicType],
	[StartCityId],
	[EventCities],
	[AttentionCount]
FROM
	[TF_EventH]
WHERE
	[Id] = @Id
GO

/******************************************************************************
******************************************************************************/
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[TF_EventHSelectAll]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
	drop procedure [dbo].[TF_EventHSelectAll]
GO

CREATE PROCEDURE [dbo].[TF_EventHSelectAll]

AS

SET NOCOUNT ON

SELECT
	[Id],
	[EventTitle],
	[StartDate],
	[EndDate],
	[dueDays],
	[Memo],
	[PicUrl],
	[OwnerId],
	[CreateDate],
	[TotalCost],
	[AttendCount],
	[StarNum],
	[PublicType],
	[StartCityId],
	[EventCities],
	[AttentionCount]
FROM
	[TF_EventH]
GO

/******************************************************************************
******************************************************************************/
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[TF_EventMarketInsert]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
	drop procedure [dbo].[TF_EventMarketInsert]
GO

CREATE PROCEDURE [dbo].[TF_EventMarketInsert] (
	@EventLineId int,
	@EventId int,
	@CityID int,
	@MarketID int,
	@StartDate varchar(10),
	@StartTime varchar(8),
	@EndDate varchar(10),
	@EndTime varchar(8),
	@Remark varchar(500),
	@LanuageId int,
	@ScheduleStatus int,
	@StepDay int,
	@LocCode varchar(30)
)

AS

SET NOCOUNT ON

INSERT INTO [TF_EventMarket] (
	[EventLineId],
	[EventId],
	[CityID],
	[MarketID],
	[StartDate],
	[StartTime],
	[EndDate],
	[EndTime],
	[Remark],
	[LanuageId],
	[ScheduleStatus],
	[StepDay],
	[LocCode]
) VALUES (
	@EventLineId,
	@EventId,
	@CityID,
	@MarketID,
	@StartDate,
	@StartTime,
	@EndDate,
	@EndTime,
	@Remark,
	@LanuageId,
	@ScheduleStatus,
	@StepDay,
	@LocCode
)

SELECT SCOPE_IDENTITY()
GO

/******************************************************************************
******************************************************************************/
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[TF_EventMarketUpdate]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
	drop procedure [dbo].[TF_EventMarketUpdate]
GO

CREATE PROCEDURE [dbo].[TF_EventMarketUpdate] (
	@ID int,
	@EventLineId int,
	@EventId int,
	@CityID int,
	@MarketID int,
	@StartDate varchar(10),
	@StartTime varchar(8),
	@EndDate varchar(10),
	@EndTime varchar(8),
	@Remark varchar(500),
	@LanuageId int,
	@ScheduleStatus int,
	@StepDay int,
	@LocCode varchar(30)
)

AS

SET NOCOUNT ON

UPDATE
	[TF_EventMarket]
SET
	[EventLineId] = @EventLineId,
	[EventId] = @EventId,
	[CityID] = @CityID,
	[MarketID] = @MarketID,
	[StartDate] = @StartDate,
	[StartTime] = @StartTime,
	[EndDate] = @EndDate,
	[EndTime] = @EndTime,
	[Remark] = @Remark,
	[LanuageId] = @LanuageId,
	[ScheduleStatus] = @ScheduleStatus,
	[StepDay] = @StepDay,
	[LocCode] = @LocCode
WHERE
	 [ID] = @ID
GO

/******************************************************************************
******************************************************************************/
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[TF_EventMarketDelete]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
	drop procedure [dbo].[TF_EventMarketDelete]
GO

CREATE PROCEDURE [dbo].[TF_EventMarketDelete] (
	@ID int
)

AS

SET NOCOUNT ON

DELETE FROM
	[TF_EventMarket]
WHERE
	[ID] = @ID
GO

/******************************************************************************
******************************************************************************/
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[TF_EventMarketSelect]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
	drop procedure [dbo].[TF_EventMarketSelect]
GO

CREATE PROCEDURE [dbo].[TF_EventMarketSelect] (
	@ID int
)

AS

SET NOCOUNT ON

SELECT
	[ID],
	[EventLineId],
	[EventId],
	[CityID],
	[MarketID],
	[StartDate],
	[StartTime],
	[EndDate],
	[EndTime],
	[Remark],
	[LanuageId],
	[ScheduleStatus],
	[StepDay],
	[LocCode]
FROM
	[TF_EventMarket]
WHERE
	[ID] = @ID
GO

/******************************************************************************
******************************************************************************/
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[TF_EventMarketSelectAll]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
	drop procedure [dbo].[TF_EventMarketSelectAll]
GO

CREATE PROCEDURE [dbo].[TF_EventMarketSelectAll]

AS

SET NOCOUNT ON

SELECT
	[ID],
	[EventLineId],
	[EventId],
	[CityID],
	[MarketID],
	[StartDate],
	[StartTime],
	[EndDate],
	[EndTime],
	[Remark],
	[LanuageId],
	[ScheduleStatus],
	[StepDay],
	[LocCode]
FROM
	[TF_EventMarket]
GO

/******************************************************************************
******************************************************************************/
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[TF_BlogInsert]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
	drop procedure [dbo].[TF_BlogInsert]
GO

CREATE PROCEDURE [dbo].[TF_BlogInsert] (
	@blog_title nvarchar(500),
	@blog_content text,
	@blog_type int,
	@blog_note nvarchar(500),
	@keyin_date datetime,
	@owner_id int,
	@reader_count int,
	@comment_count int,
	@public_type varchar(5)
)

AS

SET NOCOUNT ON

INSERT INTO [TF_Blog] (
	[blog_title],
	[blog_content],
	[blog_type],
	[blog_note],
	[keyin_date],
	[owner_id],
	[reader_count],
	[comment_count],
	[public_type]
) VALUES (
	@blog_title,
	@blog_content,
	@blog_type,
	@blog_note,
	@keyin_date,
	@owner_id,
	@reader_count,
	@comment_count,
	@public_type
)

SELECT SCOPE_IDENTITY()
GO

/******************************************************************************
******************************************************************************/
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[TF_BlogUpdate]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
	drop procedure [dbo].[TF_BlogUpdate]
GO

CREATE PROCEDURE [dbo].[TF_BlogUpdate] (
	@ID int,
	@blog_title nvarchar(500),
	@blog_content text,
	@blog_type int,
	@blog_note nvarchar(500),
	@keyin_date datetime,
	@owner_id int,
	@reader_count int,
	@comment_count int,
	@public_type varchar(5)
)

AS

SET NOCOUNT ON

UPDATE
	[TF_Blog]
SET
	[blog_title] = @blog_title,
	[blog_content] = @blog_content,
	[blog_type] = @blog_type,
	[blog_note] = @blog_note,
	[keyin_date] = @keyin_date,
	[owner_id] = @owner_id,
	[reader_count] = @reader_count,
	[comment_count] = @comment_count,
	[public_type] = @public_type
WHERE
	 [ID] = @ID
GO

/******************************************************************************
******************************************************************************/
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[TF_BlogDelete]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
	drop procedure [dbo].[TF_BlogDelete]
GO

CREATE PROCEDURE [dbo].[TF_BlogDelete] (
	@ID int
)

AS

SET NOCOUNT ON

DELETE FROM
	[TF_Blog]
WHERE
	[ID] = @ID
GO

/******************************************************************************
******************************************************************************/
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[TF_BlogSelect]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
	drop procedure [dbo].[TF_BlogSelect]
GO

CREATE PROCEDURE [dbo].[TF_BlogSelect] (
	@ID int
)

AS

SET NOCOUNT ON

SELECT
	[ID],
	[blog_title],
	[blog_content],
	[blog_type],
	[blog_note],
	[keyin_date],
	[owner_id],
	[reader_count],
	[comment_count],
	[public_type]
FROM
	[TF_Blog]
WHERE
	[ID] = @ID
GO

/******************************************************************************
******************************************************************************/
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[TF_BlogSelectAll]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
	drop procedure [dbo].[TF_BlogSelectAll]
GO

CREATE PROCEDURE [dbo].[TF_BlogSelectAll]

AS

SET NOCOUNT ON

SELECT
	[ID],
	[blog_title],
	[blog_content],
	[blog_type],
	[blog_note],
	[keyin_date],
	[owner_id],
	[reader_count],
	[comment_count],
	[public_type]
FROM
	[TF_Blog]
GO

/******************************************************************************
******************************************************************************/
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[tf_attendInsert]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
	drop procedure [dbo].[tf_attendInsert]
GO

CREATE PROCEDURE [dbo].[tf_attendInsert] (
	@uid int,
	@ehId int,
	@keyin_date datetime
)

AS

SET NOCOUNT ON

INSERT INTO [tf_attend] (
	[uid],
	[ehId],
	[keyin_date]
) VALUES (
	@uid,
	@ehId,
	@keyin_date
)
GO

/******************************************************************************
******************************************************************************/
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[tf_attendUpdate]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
	drop procedure [dbo].[tf_attendUpdate]
GO

CREATE PROCEDURE [dbo].[tf_attendUpdate] (
	@uid int,
	@ehId int,
	@keyin_date datetime
)

AS

SET NOCOUNT ON

UPDATE
	[tf_attend]
SET
	[keyin_date] = @keyin_date
WHERE
	 [uid] = @uid	AND [ehId] = @ehId
GO

/******************************************************************************
******************************************************************************/
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[tf_attendDelete]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
	drop procedure [dbo].[tf_attendDelete]
GO

CREATE PROCEDURE [dbo].[tf_attendDelete] (
	@uid int,
	@ehId int
)

AS

SET NOCOUNT ON

DELETE FROM
	[tf_attend]
WHERE
	[uid] = @uid
	AND [ehId] = @ehId
GO

/******************************************************************************
******************************************************************************/
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[tf_attendSelect]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
	drop procedure [dbo].[tf_attendSelect]
GO

CREATE PROCEDURE [dbo].[tf_attendSelect] (
	@uid int,
	@ehId int
)

AS

SET NOCOUNT ON

SELECT
	[uid],
	[ehId],
	[keyin_date]
FROM
	[tf_attend]
WHERE
	[uid] = @uid
	AND [ehId] = @ehId
GO

/******************************************************************************
******************************************************************************/
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[tf_attendSelectAll]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
	drop procedure [dbo].[tf_attendSelectAll]
GO

CREATE PROCEDURE [dbo].[tf_attendSelectAll]

AS

SET NOCOUNT ON

SELECT
	[uid],
	[ehId],
	[keyin_date]
FROM
	[tf_attend]
GO

/******************************************************************************
******************************************************************************/
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[tf_attentionInsert]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
	drop procedure [dbo].[tf_attentionInsert]
GO

CREATE PROCEDURE [dbo].[tf_attentionInsert] (
	@uid int,
	@ehId int,
	@keyin_date datetime
)

AS

SET NOCOUNT ON

INSERT INTO [tf_attention] (
	[uid],
	[ehId],
	[keyin_date]
) VALUES (
	@uid,
	@ehId,
	@keyin_date
)
GO

/******************************************************************************
******************************************************************************/
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[tf_attentionUpdate]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
	drop procedure [dbo].[tf_attentionUpdate]
GO

CREATE PROCEDURE [dbo].[tf_attentionUpdate] (
	@uid int,
	@ehId int,
	@keyin_date datetime
)

AS

SET NOCOUNT ON

UPDATE
	[tf_attention]
SET
	[keyin_date] = @keyin_date
WHERE
	 [uid] = @uid	AND [ehId] = @ehId
GO

/******************************************************************************
******************************************************************************/
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[tf_attentionDelete]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
	drop procedure [dbo].[tf_attentionDelete]
GO

CREATE PROCEDURE [dbo].[tf_attentionDelete] (
	@uid int,
	@ehId int
)

AS

SET NOCOUNT ON

DELETE FROM
	[tf_attention]
WHERE
	[uid] = @uid
	AND [ehId] = @ehId
GO

/******************************************************************************
******************************************************************************/
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[tf_attentionSelect]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
	drop procedure [dbo].[tf_attentionSelect]
GO

CREATE PROCEDURE [dbo].[tf_attentionSelect] (
	@uid int,
	@ehId int
)

AS

SET NOCOUNT ON

SELECT
	[uid],
	[ehId],
	[keyin_date]
FROM
	[tf_attention]
WHERE
	[uid] = @uid
	AND [ehId] = @ehId
GO

/******************************************************************************
******************************************************************************/
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[tf_attentionSelectAll]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
	drop procedure [dbo].[tf_attentionSelectAll]
GO

CREATE PROCEDURE [dbo].[tf_attentionSelectAll]

AS

SET NOCOUNT ON

SELECT
	[uid],
	[ehId],
	[keyin_date]
FROM
	[tf_attention]
GO

/******************************************************************************
******************************************************************************/
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[tf_blog_commentInsert]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
	drop procedure [dbo].[tf_blog_commentInsert]
GO

CREATE PROCEDURE [dbo].[tf_blog_commentInsert] (
	@blog_id int,
	@comment nvarchar(1000),
	@keyin_date datetime,
	@uid int
)

AS

SET NOCOUNT ON

INSERT INTO [tf_blog_comment] (
	[blog_id],
	[comment],
	[keyin_date],
	[uid]
) VALUES (
	@blog_id,
	@comment,
	@keyin_date,
	@uid
)

SELECT SCOPE_IDENTITY()
GO

/******************************************************************************
******************************************************************************/
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[tf_blog_commentUpdate]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
	drop procedure [dbo].[tf_blog_commentUpdate]
GO

CREATE PROCEDURE [dbo].[tf_blog_commentUpdate] (
	@id int,
	@blog_id int,
	@comment nvarchar(1000),
	@keyin_date datetime,
	@uid int
)

AS

SET NOCOUNT ON

UPDATE
	[tf_blog_comment]
SET
	[blog_id] = @blog_id,
	[comment] = @comment,
	[keyin_date] = @keyin_date,
	[uid] = @uid
WHERE
	 [id] = @id
GO

/******************************************************************************
******************************************************************************/
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[tf_blog_commentDelete]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
	drop procedure [dbo].[tf_blog_commentDelete]
GO

CREATE PROCEDURE [dbo].[tf_blog_commentDelete] (
	@id int
)

AS

SET NOCOUNT ON

DELETE FROM
	[tf_blog_comment]
WHERE
	[id] = @id
GO

/******************************************************************************
******************************************************************************/
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[tf_blog_commentSelect]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
	drop procedure [dbo].[tf_blog_commentSelect]
GO

CREATE PROCEDURE [dbo].[tf_blog_commentSelect] (
	@id int
)

AS

SET NOCOUNT ON

SELECT
	[id],
	[blog_id],
	[comment],
	[keyin_date],
	[uid]
FROM
	[tf_blog_comment]
WHERE
	[id] = @id
GO

/******************************************************************************
******************************************************************************/
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[tf_blog_commentSelectAll]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
	drop procedure [dbo].[tf_blog_commentSelectAll]
GO

CREATE PROCEDURE [dbo].[tf_blog_commentSelectAll]

AS

SET NOCOUNT ON

SELECT
	[id],
	[blog_id],
	[comment],
	[keyin_date],
	[uid]
FROM
	[tf_blog_comment]
GO

/******************************************************************************
******************************************************************************/
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[tf_friendsInsert]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
	drop procedure [dbo].[tf_friendsInsert]
GO

CREATE PROCEDURE [dbo].[tf_friendsInsert] (
	@uid int,
	@friend_uid int,
	@reply_message nvarchar(100),
	@friend_check varchar(5)
)

AS

SET NOCOUNT ON

INSERT INTO [tf_friends] (
	[uid],
	[friend_uid],
	[reply_message],
	[friend_check]
) VALUES (
	@uid,
	@friend_uid,
	@reply_message,
	@friend_check
)
GO

/******************************************************************************
******************************************************************************/
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[tf_friendsUpdate]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
	drop procedure [dbo].[tf_friendsUpdate]
GO

CREATE PROCEDURE [dbo].[tf_friendsUpdate] (
	@uid int,
	@friend_uid int,
	@reply_message nvarchar(100),
	@friend_check varchar(5)
)

AS

SET NOCOUNT ON

UPDATE
	[tf_friends]
SET
	[reply_message] = @reply_message,
	[friend_check] = @friend_check
WHERE
	 [uid] = @uid	AND [friend_uid] = @friend_uid
GO

/******************************************************************************
******************************************************************************/
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[tf_friendsDelete]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
	drop procedure [dbo].[tf_friendsDelete]
GO

CREATE PROCEDURE [dbo].[tf_friendsDelete] (
	@uid int,
	@friend_uid int
)

AS

SET NOCOUNT ON

DELETE FROM
	[tf_friends]
WHERE
	[uid] = @uid
	AND [friend_uid] = @friend_uid
GO

/******************************************************************************
******************************************************************************/
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[tf_friendsSelect]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
	drop procedure [dbo].[tf_friendsSelect]
GO

CREATE PROCEDURE [dbo].[tf_friendsSelect] (
	@uid int,
	@friend_uid int
)

AS

SET NOCOUNT ON

SELECT
	[uid],
	[friend_uid],
	[reply_message],
	[friend_check]
FROM
	[tf_friends]
WHERE
	[uid] = @uid
	AND [friend_uid] = @friend_uid
GO

/******************************************************************************
******************************************************************************/
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[tf_friendsSelectAll]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
	drop procedure [dbo].[tf_friendsSelectAll]
GO

CREATE PROCEDURE [dbo].[tf_friendsSelectAll]

AS

SET NOCOUNT ON

SELECT
	[uid],
	[friend_uid],
	[reply_message],
	[friend_check]
FROM
	[tf_friends]
GO

/******************************************************************************
******************************************************************************/
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[TF_SubPagesInsert]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
	drop procedure [dbo].[TF_SubPagesInsert]
GO

CREATE PROCEDURE [dbo].[TF_SubPagesInsert] (
	@main_pgID int,
	@sub_pgName varchar(255),
	@sub_pgTitle varchar(255),
	@sub_pgPriority int,
	@sub_dateModified datetime,
	@LanguageID int,
	@CSSName varchar(50),
	@URL varchar(250),
	@itemID int,
	@EventID int,
	@CheckedStatus int
)

AS

SET NOCOUNT ON

INSERT INTO [TF_SubPages] (
	[main_pgID],
	[sub_pgName],
	[sub_pgTitle],
	[sub_pgPriority],
	[sub_dateModified],
	[LanguageID],
	[CSSName],
	[URL],
	[itemID],
	[EventID],
	[CheckedStatus]
) VALUES (
	@main_pgID,
	@sub_pgName,
	@sub_pgTitle,
	@sub_pgPriority,
	@sub_dateModified,
	@LanguageID,
	@CSSName,
	@URL,
	@itemID,
	@EventID,
	@CheckedStatus
)

SELECT SCOPE_IDENTITY()
GO

/******************************************************************************
******************************************************************************/
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[TF_SubPagesUpdate]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
	drop procedure [dbo].[TF_SubPagesUpdate]
GO

CREATE PROCEDURE [dbo].[TF_SubPagesUpdate] (
	@sub_pgID int,
	@main_pgID int,
	@sub_pgName varchar(255),
	@sub_pgTitle varchar(255),
	@sub_pgPriority int,
	@sub_dateModified datetime,
	@LanguageID int,
	@CSSName varchar(50),
	@URL varchar(250),
	@itemID int,
	@EventID int,
	@CheckedStatus int
)

AS

SET NOCOUNT ON

UPDATE
	[TF_SubPages]
SET
	[main_pgID] = @main_pgID,
	[sub_pgName] = @sub_pgName,
	[sub_pgTitle] = @sub_pgTitle,
	[sub_pgPriority] = @sub_pgPriority,
	[sub_dateModified] = @sub_dateModified,
	[LanguageID] = @LanguageID,
	[CSSName] = @CSSName,
	[URL] = @URL,
	[itemID] = @itemID,
	[EventID] = @EventID,
	[CheckedStatus] = @CheckedStatus
WHERE
	 [sub_pgID] = @sub_pgID
GO

/******************************************************************************
******************************************************************************/
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[TF_SubPagesDelete]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
	drop procedure [dbo].[TF_SubPagesDelete]
GO

CREATE PROCEDURE [dbo].[TF_SubPagesDelete] (
	@sub_pgID int
)

AS

SET NOCOUNT ON

DELETE FROM
	[TF_SubPages]
WHERE
	[sub_pgID] = @sub_pgID
GO

/******************************************************************************
******************************************************************************/
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[TF_SubPagesSelect]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
	drop procedure [dbo].[TF_SubPagesSelect]
GO

CREATE PROCEDURE [dbo].[TF_SubPagesSelect] (
	@sub_pgID int
)

AS

SET NOCOUNT ON

SELECT
	[sub_pgID],
	[main_pgID],
	[sub_pgName],
	[sub_pgTitle],
	[sub_pgPriority],
	[sub_dateModified],
	[LanguageID],
	[CSSName],
	[URL],
	[itemID],
	[EventID],
	[CheckedStatus]
FROM
	[TF_SubPages]
WHERE
	[sub_pgID] = @sub_pgID
GO

/******************************************************************************
******************************************************************************/
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[TF_SubPagesSelectAll]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
	drop procedure [dbo].[TF_SubPagesSelectAll]
GO

CREATE PROCEDURE [dbo].[TF_SubPagesSelectAll]

AS

SET NOCOUNT ON

SELECT
	[sub_pgID],
	[main_pgID],
	[sub_pgName],
	[sub_pgTitle],
	[sub_pgPriority],
	[sub_dateModified],
	[LanguageID],
	[CSSName],
	[URL],
	[itemID],
	[EventID],
	[CheckedStatus]
FROM
	[TF_SubPages]
GO

/******************************************************************************
******************************************************************************/
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[TF_LeaveWordsInsert]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
	drop procedure [dbo].[TF_LeaveWordsInsert]
GO

CREATE PROCEDURE [dbo].[TF_LeaveWordsInsert] (
	@ElementId int,
	@Uid int,
	@LeaveWords nchar(2000),
	@keyin_date datetime,
	@ElementType varchar(50)
)

AS

SET NOCOUNT ON

INSERT INTO [TF_LeaveWords] (
	[ElementId],
	[Uid],
	[LeaveWords],
	[keyin_date],
	[ElementType]
) VALUES (
	@ElementId,
	@Uid,
	@LeaveWords,
	@keyin_date,
	@ElementType
)

SELECT SCOPE_IDENTITY()
GO

/******************************************************************************
******************************************************************************/
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[TF_LeaveWordsUpdate]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
	drop procedure [dbo].[TF_LeaveWordsUpdate]
GO

CREATE PROCEDURE [dbo].[TF_LeaveWordsUpdate] (
	@Id int,
	@ElementId int,
	@Uid int,
	@LeaveWords nchar(2000),
	@keyin_date datetime,
	@ElementType varchar(50)
)

AS

SET NOCOUNT ON

UPDATE
	[TF_LeaveWords]
SET
	[ElementId] = @ElementId,
	[Uid] = @Uid,
	[LeaveWords] = @LeaveWords,
	[keyin_date] = @keyin_date,
	[ElementType] = @ElementType
WHERE
	 [Id] = @Id
GO

/******************************************************************************
******************************************************************************/
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[TF_LeaveWordsDelete]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
	drop procedure [dbo].[TF_LeaveWordsDelete]
GO

CREATE PROCEDURE [dbo].[TF_LeaveWordsDelete] (
	@Id int
)

AS

SET NOCOUNT ON

DELETE FROM
	[TF_LeaveWords]
WHERE
	[Id] = @Id
GO

/******************************************************************************
******************************************************************************/
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[TF_LeaveWordsSelect]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
	drop procedure [dbo].[TF_LeaveWordsSelect]
GO

CREATE PROCEDURE [dbo].[TF_LeaveWordsSelect] (
	@Id int
)

AS

SET NOCOUNT ON

SELECT
	[Id],
	[ElementId],
	[Uid],
	[LeaveWords],
	[keyin_date],
	[ElementType]
FROM
	[TF_LeaveWords]
WHERE
	[Id] = @Id
GO

/******************************************************************************
******************************************************************************/
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[TF_LeaveWordsSelectAll]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
	drop procedure [dbo].[TF_LeaveWordsSelectAll]
GO

CREATE PROCEDURE [dbo].[TF_LeaveWordsSelectAll]

AS

SET NOCOUNT ON

SELECT
	[Id],
	[ElementId],
	[Uid],
	[LeaveWords],
	[keyin_date],
	[ElementType]
FROM
	[TF_LeaveWords]
GO

/******************************************************************************
******************************************************************************/
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[TF_LocationInsert]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
	drop procedure [dbo].[TF_LocationInsert]
GO

CREATE PROCEDURE [dbo].[TF_LocationInsert] (
	@LocCode varchar(30),
	@Name varchar(40),
	@Description varchar(3000),
	@ParentLocCode varchar(30),
	@LanguageId int,
	@ImageURL varchar(150),
	@IpAddressL varchar(30),
	@IpAddressH varchar(30),
	@FullName varchar(250),
	@Type int
)

AS

SET NOCOUNT ON

INSERT INTO [TF_Location] (
	[LocCode],
	[Name],
	[Description],
	[ParentLocCode],
	[LanguageId],
	[ImageURL],
	[IpAddressL],
	[IpAddressH],
	[FullName],
	[Type]
) VALUES (
	@LocCode,
	@Name,
	@Description,
	@ParentLocCode,
	@LanguageId,
	@ImageURL,
	@IpAddressL,
	@IpAddressH,
	@FullName,
	@Type
)
GO

/******************************************************************************
******************************************************************************/
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[TF_EventRestaurantInsert]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
	drop procedure [dbo].[TF_EventRestaurantInsert]
GO

CREATE PROCEDURE [dbo].[TF_EventRestaurantInsert] (
	@EventLineId int,
	@EventId int,
	@RestaurantId int,
	@CityID int,
	@RetaurantPrice decimal(18, 2),
	@StartDate varchar(10),
	@StartTime varchar(8),
	@EndDate varchar(10),
	@EndTime varchar(8),
	@Remark varchar(500),
	@ContactPerson varchar(50),
	@ContactTelephone varchar(40),
	@LanuageId int,
	@ScheduleStatus int,
	@StepDay int,
	@LocCode varchar(30)
)

AS

SET NOCOUNT ON

INSERT INTO [TF_EventRestaurant] (
	[EventLineId],
	[EventId],
	[RestaurantId],
	[CityID],
	[RetaurantPrice],
	[StartDate],
	[StartTime],
	[EndDate],
	[EndTime],
	[Remark],
	[ContactPerson],
	[ContactTelephone],
	[LanuageId],
	[ScheduleStatus],
	[StepDay],
	[LocCode]
) VALUES (
	@EventLineId,
	@EventId,
	@RestaurantId,
	@CityID,
	@RetaurantPrice,
	@StartDate,
	@StartTime,
	@EndDate,
	@EndTime,
	@Remark,
	@ContactPerson,
	@ContactTelephone,
	@LanuageId,
	@ScheduleStatus,
	@StepDay,
	@LocCode
)

SELECT SCOPE_IDENTITY()
GO

/******************************************************************************
******************************************************************************/
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[TF_EventRestaurantUpdate]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
	drop procedure [dbo].[TF_EventRestaurantUpdate]
GO

CREATE PROCEDURE [dbo].[TF_EventRestaurantUpdate] (
	@ID int,
	@EventLineId int,
	@EventId int,
	@RestaurantId int,
	@CityID int,
	@RetaurantPrice decimal(18, 2),
	@StartDate varchar(10),
	@StartTime varchar(8),
	@EndDate varchar(10),
	@EndTime varchar(8),
	@Remark varchar(500),
	@ContactPerson varchar(50),
	@ContactTelephone varchar(40),
	@LanuageId int,
	@ScheduleStatus int,
	@StepDay int,
	@LocCode varchar(30)
)

AS

SET NOCOUNT ON

UPDATE
	[TF_EventRestaurant]
SET
	[EventLineId] = @EventLineId,
	[EventId] = @EventId,
	[RestaurantId] = @RestaurantId,
	[CityID] = @CityID,
	[RetaurantPrice] = @RetaurantPrice,
	[StartDate] = @StartDate,
	[StartTime] = @StartTime,
	[EndDate] = @EndDate,
	[EndTime] = @EndTime,
	[Remark] = @Remark,
	[ContactPerson] = @ContactPerson,
	[ContactTelephone] = @ContactTelephone,
	[LanuageId] = @LanuageId,
	[ScheduleStatus] = @ScheduleStatus,
	[StepDay] = @StepDay,
	[LocCode] = @LocCode
WHERE
	 [ID] = @ID
GO

/******************************************************************************
******************************************************************************/
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[TF_EventRestaurantDelete]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
	drop procedure [dbo].[TF_EventRestaurantDelete]
GO

CREATE PROCEDURE [dbo].[TF_EventRestaurantDelete] (
	@ID int
)

AS

SET NOCOUNT ON

DELETE FROM
	[TF_EventRestaurant]
WHERE
	[ID] = @ID
GO

/******************************************************************************
******************************************************************************/
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[TF_EventRestaurantSelect]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
	drop procedure [dbo].[TF_EventRestaurantSelect]
GO

CREATE PROCEDURE [dbo].[TF_EventRestaurantSelect] (
	@ID int
)

AS

SET NOCOUNT ON

SELECT
	[ID],
	[EventLineId],
	[EventId],
	[RestaurantId],
	[CityID],
	[RetaurantPrice],
	[StartDate],
	[StartTime],
	[EndDate],
	[EndTime],
	[Remark],
	[ContactPerson],
	[ContactTelephone],
	[LanuageId],
	[ScheduleStatus],
	[StepDay],
	[LocCode]
FROM
	[TF_EventRestaurant]
WHERE
	[ID] = @ID
GO

/******************************************************************************
******************************************************************************/
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[TF_EventRestaurantSelectAll]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
	drop procedure [dbo].[TF_EventRestaurantSelectAll]
GO

CREATE PROCEDURE [dbo].[TF_EventRestaurantSelectAll]

AS

SET NOCOUNT ON

SELECT
	[ID],
	[EventLineId],
	[EventId],
	[RestaurantId],
	[CityID],
	[RetaurantPrice],
	[StartDate],
	[StartTime],
	[EndDate],
	[EndTime],
	[Remark],
	[ContactPerson],
	[ContactTelephone],
	[LanuageId],
	[ScheduleStatus],
	[StepDay],
	[LocCode]
FROM
	[TF_EventRestaurant]
GO

/******************************************************************************
******************************************************************************/
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[TF_Blog_TmpInsert]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
	drop procedure [dbo].[TF_Blog_TmpInsert]
GO

CREATE PROCEDURE [dbo].[TF_Blog_TmpInsert] (
	@blog_title nvarchar(500),
	@blog_content text,
	@blog_type int,
	@blog_note nvarchar(500),
	@keyin_date datetime,
	@owner_id int,
	@reader_count int,
	@comment_count int,
	@public_type varchar(5)
)

AS

SET NOCOUNT ON

INSERT INTO [TF_Blog_Tmp] (
	[blog_title],
	[blog_content],
	[blog_type],
	[blog_note],
	[keyin_date],
	[owner_id],
	[reader_count],
	[comment_count],
	[public_type]
) VALUES (
	@blog_title,
	@blog_content,
	@blog_type,
	@blog_note,
	@keyin_date,
	@owner_id,
	@reader_count,
	@comment_count,
	@public_type
)

SELECT SCOPE_IDENTITY()
GO

/******************************************************************************
******************************************************************************/
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[TF_Blog_TmpUpdate]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
	drop procedure [dbo].[TF_Blog_TmpUpdate]
GO

CREATE PROCEDURE [dbo].[TF_Blog_TmpUpdate] (
	@ID int,
	@blog_title nvarchar(500),
	@blog_content text,
	@blog_type int,
	@blog_note nvarchar(500),
	@keyin_date datetime,
	@owner_id int,
	@reader_count int,
	@comment_count int,
	@public_type varchar(5)
)

AS

SET NOCOUNT ON

UPDATE
	[TF_Blog_Tmp]
SET
	[blog_title] = @blog_title,
	[blog_content] = @blog_content,
	[blog_type] = @blog_type,
	[blog_note] = @blog_note,
	[keyin_date] = @keyin_date,
	[owner_id] = @owner_id,
	[reader_count] = @reader_count,
	[comment_count] = @comment_count,
	[public_type] = @public_type
WHERE
	 [ID] = @ID
GO

/******************************************************************************
******************************************************************************/
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[TF_Blog_TmpDelete]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
	drop procedure [dbo].[TF_Blog_TmpDelete]
GO

CREATE PROCEDURE [dbo].[TF_Blog_TmpDelete] (
	@ID int
)

AS

SET NOCOUNT ON

DELETE FROM
	[TF_Blog_Tmp]
WHERE
	[ID] = @ID
GO

/******************************************************************************
******************************************************************************/
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[TF_Blog_TmpSelect]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
	drop procedure [dbo].[TF_Blog_TmpSelect]
GO

CREATE PROCEDURE [dbo].[TF_Blog_TmpSelect] (
	@ID int
)

AS

SET NOCOUNT ON

SELECT
	[ID],
	[blog_title],
	[blog_content],
	[blog_type],
	[blog_note],
	[keyin_date],
	[owner_id],
	[reader_count],
	[comment_count],
	[public_type]
FROM
	[TF_Blog_Tmp]
WHERE
	[ID] = @ID
GO

/******************************************************************************
******************************************************************************/
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[TF_Blog_TmpSelectAll]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
	drop procedure [dbo].[TF_Blog_TmpSelectAll]
GO

CREATE PROCEDURE [dbo].[TF_Blog_TmpSelectAll]

AS

SET NOCOUNT ON

SELECT
	[ID],
	[blog_title],
	[blog_content],
	[blog_type],
	[blog_note],
	[keyin_date],
	[owner_id],
	[reader_count],
	[comment_count],
	[public_type]
FROM
	[TF_Blog_Tmp]
GO

/******************************************************************************
******************************************************************************/
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[TF_EventHotelInsert]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
	drop procedure [dbo].[TF_EventHotelInsert]
GO

CREATE PROCEDURE [dbo].[TF_EventHotelInsert] (
	@EventId int,
	@HotelId int,
	@CityID int,
	@HotelPrice decimal(18, 2),
	@StartDate varchar(10),
	@StartTime varchar(8),
	@EndDate varchar(10),
	@EndTime varchar(8),
	@Remark varchar(500),
	@EventLineId int,
	@LanuageId int,
	@ScheduleStatus int,
	@StepDay int,
	@StartHour int,
	@StartMin int,
	@Duration int,
	@TimeStatus int,
	@LocCode varchar(30)
)

AS

SET NOCOUNT ON

INSERT INTO [TF_EventHotel] (
	[EventId],
	[HotelId],
	[CityID],
	[HotelPrice],
	[StartDate],
	[StartTime],
	[EndDate],
	[EndTime],
	[Remark],
	[EventLineId],
	[LanuageId],
	[ScheduleStatus],
	[StepDay],
	[StartHour],
	[StartMin],
	[Duration],
	[TimeStatus],
	[LocCode]
) VALUES (
	@EventId,
	@HotelId,
	@CityID,
	@HotelPrice,
	@StartDate,
	@StartTime,
	@EndDate,
	@EndTime,
	@Remark,
	@EventLineId,
	@LanuageId,
	@ScheduleStatus,
	@StepDay,
	@StartHour,
	@StartMin,
	@Duration,
	@TimeStatus,
	@LocCode
)

SELECT SCOPE_IDENTITY()
GO

/******************************************************************************
******************************************************************************/
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[TF_EventHotelUpdate]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
	drop procedure [dbo].[TF_EventHotelUpdate]
GO

CREATE PROCEDURE [dbo].[TF_EventHotelUpdate] (
	@ID int,
	@EventId int,
	@HotelId int,
	@CityID int,
	@HotelPrice decimal(18, 2),
	@StartDate varchar(10),
	@StartTime varchar(8),
	@EndDate varchar(10),
	@EndTime varchar(8),
	@Remark varchar(500),
	@EventLineId int,
	@LanuageId int,
	@ScheduleStatus int,
	@StepDay int,
	@StartHour int,
	@StartMin int,
	@Duration int,
	@TimeStatus int,
	@LocCode varchar(30)
)

AS

SET NOCOUNT ON

UPDATE
	[TF_EventHotel]
SET
	[EventId] = @EventId,
	[HotelId] = @HotelId,
	[CityID] = @CityID,
	[HotelPrice] = @HotelPrice,
	[StartDate] = @StartDate,
	[StartTime] = @StartTime,
	[EndDate] = @EndDate,
	[EndTime] = @EndTime,
	[Remark] = @Remark,
	[EventLineId] = @EventLineId,
	[LanuageId] = @LanuageId,
	[ScheduleStatus] = @ScheduleStatus,
	[StepDay] = @StepDay,
	[StartHour] = @StartHour,
	[StartMin] = @StartMin,
	[Duration] = @Duration,
	[TimeStatus] = @TimeStatus,
	[LocCode] = @LocCode
WHERE
	 [ID] = @ID
GO

/******************************************************************************
******************************************************************************/
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[TF_EventHotelDelete]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
	drop procedure [dbo].[TF_EventHotelDelete]
GO

CREATE PROCEDURE [dbo].[TF_EventHotelDelete] (
	@ID int
)

AS

SET NOCOUNT ON

DELETE FROM
	[TF_EventHotel]
WHERE
	[ID] = @ID
GO

/******************************************************************************
******************************************************************************/
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[TF_EventHotelSelect]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
	drop procedure [dbo].[TF_EventHotelSelect]
GO

CREATE PROCEDURE [dbo].[TF_EventHotelSelect] (
	@ID int
)

AS

SET NOCOUNT ON

SELECT
	[ID],
	[EventId],
	[HotelId],
	[CityID],
	[HotelPrice],
	[StartDate],
	[StartTime],
	[EndDate],
	[EndTime],
	[Remark],
	[EventLineId],
	[LanuageId],
	[ScheduleStatus],
	[StepDay],
	[StartHour],
	[StartMin],
	[Duration],
	[TimeStatus],
	[LocCode]
FROM
	[TF_EventHotel]
WHERE
	[ID] = @ID
GO

/******************************************************************************
******************************************************************************/
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[TF_EventHotelSelectAll]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
	drop procedure [dbo].[TF_EventHotelSelectAll]
GO

CREATE PROCEDURE [dbo].[TF_EventHotelSelectAll]

AS

SET NOCOUNT ON

SELECT
	[ID],
	[EventId],
	[HotelId],
	[CityID],
	[HotelPrice],
	[StartDate],
	[StartTime],
	[EndDate],
	[EndTime],
	[Remark],
	[EventLineId],
	[LanuageId],
	[ScheduleStatus],
	[StepDay],
	[StartHour],
	[StartMin],
	[Duration],
	[TimeStatus],
	[LocCode]
FROM
	[TF_EventHotel]
GO

/******************************************************************************
******************************************************************************/
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[TF_UserProfileInsert]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
	drop procedure [dbo].[TF_UserProfileInsert]
GO

CREATE PROCEDURE [dbo].[TF_UserProfileInsert] (
	@CN_Name varchar(50),
	@EN_Name varchar(50),
	@CountryID int,
	@ProvinceID int,
	@CityID int,
	@DistrictId int,
	@pwd varchar(16),
	@Nick_Name varchar(50),
	@Gender varchar(1),
	@Home varchar(100),
	@Email varchar(50),
	@BirthYear varchar(4),
	@BirthMonth varchar(50),
	@BirthDay varchar(2),
	@Interesting_Place varchar(100),
	@IsRegister tinyint,
	@IsBlogProhibited tinyint,
	@HomeProvinceId int,
	@HomeCityId int,
	@Pic varchar(50),
	@MobilePhone varchar(50),
	@QQ varchar(20),
	@MSN varchar(100),
	@IsPublicGender tinyint,
	@IsPublicBirthDay tinyint,
	@IsPublicHome tinyint,
	@IsPublicAddress tinyint,
	@keyin_date datetime,
	@modi_date datetime
)

AS

SET NOCOUNT ON

INSERT INTO [TF_UserProfile] (
	[CN_Name],
	[EN_Name],
	[CountryID],
	[ProvinceID],
	[CityID],
	[DistrictId],
	[pwd],
	[Nick_Name],
	[Gender],
	[Home],
	[Email],
	[BirthYear],
	[BirthMonth],
	[BirthDay],
	[Interesting_Place],
	[IsRegister],
	[IsBlogProhibited],
	[HomeProvinceId],
	[HomeCityId],
	[Pic],
	[MobilePhone],
	[QQ],
	[MSN],
	[IsPublicGender],
	[IsPublicBirthDay],
	[IsPublicHome],
	[IsPublicAddress],
	[keyin_date],
	[modi_date]
) VALUES (
	@CN_Name,
	@EN_Name,
	@CountryID,
	@ProvinceID,
	@CityID,
	@DistrictId,
	@pwd,
	@Nick_Name,
	@Gender,
	@Home,
	@Email,
	@BirthYear,
	@BirthMonth,
	@BirthDay,
	@Interesting_Place,
	@IsRegister,
	@IsBlogProhibited,
	@HomeProvinceId,
	@HomeCityId,
	@Pic,
	@MobilePhone,
	@QQ,
	@MSN,
	@IsPublicGender,
	@IsPublicBirthDay,
	@IsPublicHome,
	@IsPublicAddress,
	@keyin_date,
	@modi_date
)

SELECT SCOPE_IDENTITY()
GO

/******************************************************************************
******************************************************************************/
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[TF_UserProfileUpdate]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
	drop procedure [dbo].[TF_UserProfileUpdate]
GO

CREATE PROCEDURE [dbo].[TF_UserProfileUpdate] (
	@Uid int,
	@CN_Name varchar(50),
	@EN_Name varchar(50),
	@CountryID int,
	@ProvinceID int,
	@CityID int,
	@DistrictId int,
	@pwd varchar(16),
	@Nick_Name varchar(50),
	@Gender varchar(1),
	@Home varchar(100),
	@Email varchar(50),
	@BirthYear varchar(4),
	@BirthMonth varchar(50),
	@BirthDay varchar(2),
	@Interesting_Place varchar(100),
	@IsRegister tinyint,
	@IsBlogProhibited tinyint,
	@HomeProvinceId int,
	@HomeCityId int,
	@Pic varchar(50),
	@MobilePhone varchar(50),
	@QQ varchar(20),
	@MSN varchar(100),
	@IsPublicGender tinyint,
	@IsPublicBirthDay tinyint,
	@IsPublicHome tinyint,
	@IsPublicAddress tinyint,
	@keyin_date datetime,
	@modi_date datetime
)

AS

SET NOCOUNT ON

UPDATE
	[TF_UserProfile]
SET
	[CN_Name] = @CN_Name,
	[EN_Name] = @EN_Name,
	[CountryID] = @CountryID,
	[ProvinceID] = @ProvinceID,
	[CityID] = @CityID,
	[DistrictId] = @DistrictId,
	[pwd] = @pwd,
	[Nick_Name] = @Nick_Name,
	[Gender] = @Gender,
	[Home] = @Home,
	[Email] = @Email,
	[BirthYear] = @BirthYear,
	[BirthMonth] = @BirthMonth,
	[BirthDay] = @BirthDay,
	[Interesting_Place] = @Interesting_Place,
	[IsRegister] = @IsRegister,
	[IsBlogProhibited] = @IsBlogProhibited,
	[HomeProvinceId] = @HomeProvinceId,
	[HomeCityId] = @HomeCityId,
	[Pic] = @Pic,
	[MobilePhone] = @MobilePhone,
	[QQ] = @QQ,
	[MSN] = @MSN,
	[IsPublicGender] = @IsPublicGender,
	[IsPublicBirthDay] = @IsPublicBirthDay,
	[IsPublicHome] = @IsPublicHome,
	[IsPublicAddress] = @IsPublicAddress,
	[keyin_date] = @keyin_date,
	[modi_date] = @modi_date
WHERE
	 [Uid] = @Uid
GO

/******************************************************************************
******************************************************************************/
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[TF_UserProfileDelete]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
	drop procedure [dbo].[TF_UserProfileDelete]
GO

CREATE PROCEDURE [dbo].[TF_UserProfileDelete] (
	@Uid int
)

AS

SET NOCOUNT ON

DELETE FROM
	[TF_UserProfile]
WHERE
	[Uid] = @Uid
GO

/******************************************************************************
******************************************************************************/
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[TF_UserProfileSelect]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
	drop procedure [dbo].[TF_UserProfileSelect]
GO

CREATE PROCEDURE [dbo].[TF_UserProfileSelect] (
	@Uid int
)

AS

SET NOCOUNT ON

SELECT
	[Uid],
	[CN_Name],
	[EN_Name],
	[CountryID],
	[ProvinceID],
	[CityID],
	[DistrictId],
	[pwd],
	[Nick_Name],
	[Gender],
	[Home],
	[Email],
	[BirthYear],
	[BirthMonth],
	[BirthDay],
	[Interesting_Place],
	[IsRegister],
	[IsBlogProhibited],
	[HomeProvinceId],
	[HomeCityId],
	[Pic],
	[MobilePhone],
	[QQ],
	[MSN],
	[IsPublicGender],
	[IsPublicBirthDay],
	[IsPublicHome],
	[IsPublicAddress],
	[keyin_date],
	[modi_date]
FROM
	[TF_UserProfile]
WHERE
	[Uid] = @Uid
GO

/******************************************************************************
******************************************************************************/
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[TF_UserProfileSelectAll]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
	drop procedure [dbo].[TF_UserProfileSelectAll]
GO

CREATE PROCEDURE [dbo].[TF_UserProfileSelectAll]

AS

SET NOCOUNT ON

SELECT
	[Uid],
	[CN_Name],
	[EN_Name],
	[CountryID],
	[ProvinceID],
	[CityID],
	[DistrictId],
	[pwd],
	[Nick_Name],
	[Gender],
	[Home],
	[Email],
	[BirthYear],
	[BirthMonth],
	[BirthDay],
	[Interesting_Place],
	[IsRegister],
	[IsBlogProhibited],
	[HomeProvinceId],
	[HomeCityId],
	[Pic],
	[MobilePhone],
	[QQ],
	[MSN],
	[IsPublicGender],
	[IsPublicBirthDay],
	[IsPublicHome],
	[IsPublicAddress],
	[keyin_date],
	[modi_date]
FROM
	[TF_UserProfile]
GO

/******************************************************************************
******************************************************************************/
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[TF_MainPagesInsert]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
	drop procedure [dbo].[TF_MainPagesInsert]
GO

CREATE PROCEDURE [dbo].[TF_MainPagesInsert] (
	@main_pgID int,
	@main_pgName varchar(255),
	@main_pgTitle varchar(255),
	@main_pgPriority int,
	@main_dateModified datetime,
	@LanguageID int,
	@MenuType int,
	@URL varchar(250),
	@CSSName varchar(50)
)

AS

SET NOCOUNT ON

INSERT INTO [TF_MainPages] (
	[main_pgID],
	[main_pgName],
	[main_pgTitle],
	[main_pgPriority],
	[main_dateModified],
	[LanguageID],
	[MenuType],
	[URL],
	[CSSName]
) VALUES (
	@main_pgID,
	@main_pgName,
	@main_pgTitle,
	@main_pgPriority,
	@main_dateModified,
	@LanguageID,
	@MenuType,
	@URL,
	@CSSName
)

SELECT SCOPE_IDENTITY()
GO

/******************************************************************************
******************************************************************************/
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[TF_MainPagesUpdate]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
	drop procedure [dbo].[TF_MainPagesUpdate]
GO

CREATE PROCEDURE [dbo].[TF_MainPagesUpdate] (
	@ID int,
	@main_pgID int,
	@main_pgName varchar(255),
	@main_pgTitle varchar(255),
	@main_pgPriority int,
	@main_dateModified datetime,
	@LanguageID int,
	@MenuType int,
	@URL varchar(250),
	@CSSName varchar(50)
)

AS

SET NOCOUNT ON

UPDATE
	[TF_MainPages]
SET
	[main_pgID] = @main_pgID,
	[main_pgName] = @main_pgName,
	[main_pgTitle] = @main_pgTitle,
	[main_pgPriority] = @main_pgPriority,
	[main_dateModified] = @main_dateModified,
	[LanguageID] = @LanguageID,
	[MenuType] = @MenuType,
	[URL] = @URL,
	[CSSName] = @CSSName
WHERE
	 [ID] = @ID
GO

/******************************************************************************
******************************************************************************/
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[TF_MainPagesDelete]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
	drop procedure [dbo].[TF_MainPagesDelete]
GO

CREATE PROCEDURE [dbo].[TF_MainPagesDelete] (
	@ID int
)

AS

SET NOCOUNT ON

DELETE FROM
	[TF_MainPages]
WHERE
	[ID] = @ID
GO

/******************************************************************************
******************************************************************************/
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[TF_MainPagesSelect]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
	drop procedure [dbo].[TF_MainPagesSelect]
GO

CREATE PROCEDURE [dbo].[TF_MainPagesSelect] (
	@ID int
)

AS

SET NOCOUNT ON

SELECT
	[ID],
	[main_pgID],
	[main_pgName],
	[main_pgTitle],
	[main_pgPriority],
	[main_dateModified],
	[LanguageID],
	[MenuType],
	[URL],
	[CSSName]
FROM
	[TF_MainPages]
WHERE
	[ID] = @ID
GO

/******************************************************************************
******************************************************************************/
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[TF_MainPagesSelectAll]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
	drop procedure [dbo].[TF_MainPagesSelectAll]
GO

CREATE PROCEDURE [dbo].[TF_MainPagesSelectAll]

AS

SET NOCOUNT ON

SELECT
	[ID],
	[main_pgID],
	[main_pgName],
	[main_pgTitle],
	[main_pgPriority],
	[main_dateModified],
	[LanguageID],
	[MenuType],
	[URL],
	[CSSName]
FROM
	[TF_MainPages]
GO

/******************************************************************************
******************************************************************************/
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[TF_TripParamInsert]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
	drop procedure [dbo].[TF_TripParamInsert]
GO

CREATE PROCEDURE [dbo].[TF_TripParamInsert] (
	@text varchar(50),
	@type varchar(5)
)

AS

SET NOCOUNT ON

INSERT INTO [TF_TripParam] (
	[text],
	[type]
) VALUES (
	@text,
	@type
)

SELECT SCOPE_IDENTITY()
GO

/******************************************************************************
******************************************************************************/
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[TF_TripParamUpdate]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
	drop procedure [dbo].[TF_TripParamUpdate]
GO

CREATE PROCEDURE [dbo].[TF_TripParamUpdate] (
	@ID int,
	@text varchar(50),
	@type varchar(5)
)

AS

SET NOCOUNT ON

UPDATE
	[TF_TripParam]
SET
	[text] = @text,
	[type] = @type
WHERE
	 [ID] = @ID
GO

/******************************************************************************
******************************************************************************/
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[TF_TripParamDelete]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
	drop procedure [dbo].[TF_TripParamDelete]
GO

CREATE PROCEDURE [dbo].[TF_TripParamDelete] (
	@ID int
)

AS

SET NOCOUNT ON

DELETE FROM
	[TF_TripParam]
WHERE
	[ID] = @ID
GO

/******************************************************************************
******************************************************************************/
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[TF_TripParamSelect]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
	drop procedure [dbo].[TF_TripParamSelect]
GO

CREATE PROCEDURE [dbo].[TF_TripParamSelect] (
	@ID int
)

AS

SET NOCOUNT ON

SELECT
	[ID],
	[text],
	[type]
FROM
	[TF_TripParam]
WHERE
	[ID] = @ID
GO

/******************************************************************************
******************************************************************************/
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[TF_TripParamSelectAll]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
	drop procedure [dbo].[TF_TripParamSelectAll]
GO

CREATE PROCEDURE [dbo].[TF_TripParamSelectAll]

AS

SET NOCOUNT ON

SELECT
	[ID],
	[text],
	[type]
FROM
	[TF_TripParam]
GO

/******************************************************************************
******************************************************************************/
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[tf_log_typeInsert]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
	drop procedure [dbo].[tf_log_typeInsert]
GO

CREATE PROCEDURE [dbo].[tf_log_typeInsert] (
	@log_type varchar(5),
	@log_type_desc varchar(50),
	@log_display_template nvarchar(2000)
)

AS

SET NOCOUNT ON

INSERT INTO [tf_log_type] (
	[log_type],
	[log_type_desc],
	[log_display_template]
) VALUES (
	@log_type,
	@log_type_desc,
	@log_display_template
)
GO

/******************************************************************************
******************************************************************************/
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[tf_log_typeUpdate]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
	drop procedure [dbo].[tf_log_typeUpdate]
GO

CREATE PROCEDURE [dbo].[tf_log_typeUpdate] (
	@log_type varchar(5),
	@log_type_desc varchar(50),
	@log_display_template nvarchar(2000)
)

AS

SET NOCOUNT ON

UPDATE
	[tf_log_type]
SET
	[log_type_desc] = @log_type_desc,
	[log_display_template] = @log_display_template
WHERE
	 [log_type] = @log_type
GO

/******************************************************************************
******************************************************************************/
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[tf_log_typeDelete]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
	drop procedure [dbo].[tf_log_typeDelete]
GO

CREATE PROCEDURE [dbo].[tf_log_typeDelete] (
	@log_type varchar(5)
)

AS

SET NOCOUNT ON

DELETE FROM
	[tf_log_type]
WHERE
	[log_type] = @log_type
GO

/******************************************************************************
******************************************************************************/
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[tf_log_typeSelect]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
	drop procedure [dbo].[tf_log_typeSelect]
GO

CREATE PROCEDURE [dbo].[tf_log_typeSelect] (
	@log_type varchar(5)
)

AS

SET NOCOUNT ON

SELECT
	[log_type],
	[log_type_desc],
	[log_display_template]
FROM
	[tf_log_type]
WHERE
	[log_type] = @log_type
GO

/******************************************************************************
******************************************************************************/
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[tf_log_typeSelectAll]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
	drop procedure [dbo].[tf_log_typeSelectAll]
GO

CREATE PROCEDURE [dbo].[tf_log_typeSelectAll]

AS

SET NOCOUNT ON

SELECT
	[log_type],
	[log_type_desc],
	[log_display_template]
FROM
	[tf_log_type]
GO
